Hi everyone
in activity, it's easy to call sub from in Line java to b4a, for example
[CODE lang="b4x" title="call sub from java to b4a in activity"]Sub Activity_Create(FirstTime As Boolean)
Private jo As JavaObject
jo.InitializeContext
jo.RunMethod("startPreview1",Null)
End Sub
Private Sub send_qv(s As String)
Log(s)
End Sub
#if java
public void startPreview1() {
subQvEvent("send","Mohammad");
}
public void subQvEvent(String EventName,String values) {
processBA.raiseEventFromUI(this, EventName.toLowerCase(BA.cul) + "_qv", values);
}
#End If
[/CODE]
but in b4aClass, I do not understand where the error comes from, here is my code
[CODE lang="b4x" title="call sub from in Line java to b4a in b4aClass Module"]Public Sub Initialize
Private jo As JavaObject
jo.InitializeNewInstance(Application.PackageName&".check.thisQv", Array(Null))
jo.RunMethod("startPreview1",Null)
End Sub
Private Sub send_qv(s As String)
Log(s)
End Sub
#if java
public class thisQv{
import anywheresoftware.b4a.BA;
public BA processBA;
public BA ba;
public void startPreview1() {
subQvEvent("send","Mohammad");
}
public void subQvEvent(String EventName,String values) {
processBA.raiseEventFromUI(this, EventName.toLowerCase(BA.cul) + "_qv", values);
}
}
#End If[/CODE]
and this error :
[CODE lang="b4x" title="error"]Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.BA.raiseEventFromUI(java.lang.Object, java.lang.String, java.lang.Object[])' on a null object reference
[/CODE]
These are other codes that I tried and unfortunately got the same error.
[CODE lang="b4x" title="call sub from java to b4a in b4aClass"]
processBA.raiseEventFromUI(this, EventName.toLowerCase(BA.cul) + "_qv", values);
ba.raiseEvent(this,EventName.toLowerCase(BA.cul) + "_qv", values);
ba.raiseEvent(ba,EventName.toLowerCase(BA.cul) + "_qv", values);
ba.raiseEvent2(null, true, EventName.toLowerCase(BA.cul) + "_qv",false,values);[/CODE]
My main question is that, How call Sub From in Line java to B4a Class Module.
Thanks.