Below a simplified version of the code, but my B4J code is not being called ("callback").
Is it possible to have the java code call a function in B4J (synchroneously) and receive the result of the B4J code ?
Thanks !
B4X:
public Sub StartServer
Dim obj As JavaObject = Me
obj.RunMethod("StartServer", Null)
End Sub
Public Sub callback (txt As String)
Log (txt)
End Sub
#if java
public void StartServer() {
ba.raiseEventFromUI(this, "_callback", null);
}
#end if
Having tried it, it does support raiseEventFromUI, you just need to provide a parameter:
B4X:
public Sub StartServer
Dim obj As JavaObject = Me
obj.RunMethod("StartServer", Null)
End Sub
Public Sub callback (txt As String)
Log (txt)
End Sub
#if java
public void StartServer() {
ba.raiseEventFromUI(this, "callback", "Text");
}
#end if
Or
B4X:
public Sub StartServer
Dim obj As JavaObject = Me
obj.RunMethod("StartServer", Array("Param"))
End Sub
Public Sub callback (txt As String)
Log (txt)
End Sub
#if java
public void StartServer(String text) {
ba.raiseEventFromUI(this, "callback", text);
}
#end if