B4J Question Inline JAVA - List and raiseEventFromUI...

Magma

Expert
Licensed User
Longtime User
Hi there...

my little-knowledge to java limit me again.. :-(

is it possible from inline java send an array of object or list to B4J... whatever... and how ?
I have a byte array and an integer - how i will do that...

until now...
B4X:
                        anywheresoftware.b4a.objects.collections.List list = new anywheresoftware.b4a.objects.collections.List();
                        list.setObject(finalCompressedArray);
                        list.setObject(decompressedLength);
                        ba.raiseEventFromUI(this, "myback", list);     //this

...but i think i am wrong...
because getting:

src\b4j\example\cap.java:305: error: incompatible types: byte[] cannot be converted to List<Object>
list.setObject(finalCompressedArray);
 
Solution
list.setObject(finalCompressedArray); list.setObject(decompressedLength);
should be
Java:
list.Add(finalCompressedArray);
list.Add(decompressedLength);

You should also be able to do
Java:
ba.raiseEventFromUI(this, "myback", new Object[] {finalCompressedArray, decompressedLength);

And your sub would be
B4X:
Public Sub myback(compressed As Byte(), length As Int)
End Sub

OliverA

Expert
Licensed User
Longtime User
list.setObject(finalCompressedArray); list.setObject(decompressedLength);
should be
Java:
list.Add(finalCompressedArray);
list.Add(decompressedLength);

You should also be able to do
Java:
ba.raiseEventFromUI(this, "myback", new Object[] {finalCompressedArray, decompressedLength);

And your sub would be
B4X:
Public Sub myback(compressed As Byte(), length As Int)
End Sub
 
Upvote 1
Solution

Magma

Expert
Licensed User
Longtime User
should be
Java:
list.Add(finalCompressedArray);
list.Add(decompressedLength);

You should also be able to do
Java:
ba.raiseEventFromUI(this, "myback", new Object[] {finalCompressedArray, decompressedLength);

And your sub would be
B4X:
Public Sub myback(compressed As Byte(), length As Int)
End Sub
Thanks for explaining!
 
Upvote 0
Top