Android Question How to get the return value of getBA().raiseEventFromUI

BOHANG

Member
I want to know how to get the return value from a function called B4X from inline JAVA.


B4X:
Private Sub Button1_Click
Me.As(JavaObject).RunMethod("sum", Array(1,2))
End Sub

Sub getsum(a As Int,b As Int) As String
Return a+b
End Sub

#if java
public void sum(Int a,Int b){
    getBA().raiseEventFromUI(this, "getsum",a,b);
    BA.Log(???); //How to get the return value=3
}
#End If
 

BOHANG

Member
The first question has not been answered yet, and now there is also a new question. How to call Resumable subs that return values from inline JAVA


B4X:
Sub a()As ResumableSub
dim i as int
for i = 1 to 10
    log(i)
    sleep(10)
next
return true
End Sub

#if java
public void test(){
   // How to use functions like Wait for to call a here
    BA.Log("finish");
}
#End If
 
Upvote 0

BOHANG

Member
raiseEventFromUI cannot return a value as the event isn't raised immediately. You need to use raiseEvent instead. This adds some other complexities.


Impossible.

Tip: don't waste your time with Java. Write B4X code.
Because my program is related to smart homes, end users can use LUA scripts to write usage logic based on actual results
 
Upvote 0
Top