Android Question how to deal (Context context) { this.context = context; }

hears

Active Member
Licensed User
Longtime User
I am making a library now.
in java code function need "context context".
how to pass from b4a ?

B4X:
public void setCameraSurfaceHolder(Context context, SurfaceView surfaceView) {
        this.context = context;
        this.surfaceView = surfaceView;
        surfaceHolder = surfaceView.getHolder();
        surfaceHolder.addCallback(callback);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        callback.setContext(context);
    }
 

drgottjr

Expert
Licensed User
Longtime User
Context context = BA.applicationContext;
presumably you already have this at the top: import anywheresoftware.b4a.BA.*;

also in b4a in you prefer:
B4X:
Sub GetContext As JavaObject
   Return GetBA.GetField("context")
End Sub
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

hears

Active Member
Licensed User
Longtime User
Context context = BA.applicationContext;
presumably you already have this at the top: import anywheresoftware.b4a.BA.*;

also in b4a in you prefer:
B4X:
Sub GetContext As JavaObject
   Return GetBA.GetField("context")
End Sub
thank you. it is working now.
 
Upvote 0

hears

Active Member
Licensed User
Longtime User
Upvote 0
Top