hears Active Member Licensed User Longtime User Apr 1, 2020 #1 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); }
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 Apr 1, 2020 #2 Context context = BA.applicationContext; presumably you already have this at the top: import anywheresoftware.b4a.BA.*; also in b4a in you prefer: Code: Sub GetContext As JavaObject Return GetBA.GetField("context") End Sub Upvote 0
Context context = BA.applicationContext; presumably you already have this at the top: import anywheresoftware.b4a.BA.*; also in b4a in you prefer: Code: Sub GetContext As JavaObject Return GetBA.GetField("context") End Sub
OliverA Expert Licensed User Longtime User Apr 1, 2020 #3 drgottjr said: also in b4a in you prefer: Click to expand... Missing the GetBA method: Code: Sub GetBA As JavaObject Dim jo As JavaObject Dim cls As String = Me cls = cls.SubString("class ".Length) jo.InitializeStatic(cls) Return jo.GetFieldJO("processBA") End Sub Source: https://www.b4x.com/android/forum/t...h-additionaljar-and-javaobject-picasso.40904/ Upvote 0
drgottjr said: also in b4a in you prefer: Click to expand... Missing the GetBA method: Code: Sub GetBA As JavaObject Dim jo As JavaObject Dim cls As String = Me cls = cls.SubString("class ".Length) jo.InitializeStatic(cls) Return jo.GetFieldJO("processBA") End Sub Source: https://www.b4x.com/android/forum/t...h-additionaljar-and-javaobject-picasso.40904/
hears Active Member Licensed User Longtime User Apr 1, 2020 #4 drgottjr said: Context context = BA.applicationContext; presumably you already have this at the top: import anywheresoftware.b4a.BA.*; also in b4a in you prefer: Code: Sub GetContext As JavaObject Return GetBA.GetField("context") End Sub Click to expand... thank you. it is working now. Upvote 0
drgottjr said: Context context = BA.applicationContext; presumably you already have this at the top: import anywheresoftware.b4a.BA.*; also in b4a in you prefer: Code: Sub GetContext As JavaObject Return GetBA.GetField("context") End Sub Click to expand... thank you. it is working now.
hears Active Member Licensed User Longtime User Apr 1, 2020 #5 OliverA said: Missing the GetBA method: Code: Sub GetBA As JavaObject Dim jo As JavaObject Dim cls As String = Me cls = cls.SubString("class ".Length) jo.InitializeStatic(cls) Return jo.GetFieldJO("processBA") End Sub Source: https://www.b4x.com/android/forum/t...h-additionaljar-and-javaobject-picasso.40904/ Click to expand... thank you, working now Upvote 0
OliverA said: Missing the GetBA method: Code: Sub GetBA As JavaObject Dim jo As JavaObject Dim cls As String = Me cls = cls.SubString("class ".Length) jo.InitializeStatic(cls) Return jo.GetFieldJO("processBA") End Sub Source: https://www.b4x.com/android/forum/t...h-additionaljar-and-javaobject-picasso.40904/ Click to expand... thank you, working now
Erel B4X founder Staff member Licensed User Longtime User Apr 1, 2020 #6 Correct way to get Context is with JavaObject.InitializeContext. Upvote 0