Android Question [SOLVED] ArrayList, JavaObject and datas extraction

sirjo66

Well-Known Member
Licensed User
Longtime User
Hello to all :)
in an event I receive two objects, here is the code:
B4X:
Sub acs_OnAccessibilityEvent (Event As Object, node As Object)
Now I need to extract datas from "node" object, but node object is an ArrayList java object, so:
B4X:
Dim Jo As JavaObject = node
Dim size As Int = Jo.RunMethod("size", Array As Object())
           
If size > 0 Then ' if there is objects
    Jo = Jo.RunMethod("get", Array As Object(0)) ' extract first object on the list (that is another ArrayList)
    size = Jo.RunMethod("size", Array As Object()) ' size of the ArrayList
    Log("Size = " & size) ' until here is correct !!
               
    For x = 0 To size - 1
        Dim Jo2 As JavaObject = Jo.RunMethod("get", Array As Object(x)) ' extract object number x
        ' now I need to extract (for example) "mClassName" property of this object, but
        ' I don't know how to do it
        ' I try two line below (one at time), but error on each of it
        Dim ViewId As String =  Jo2.GetField("mClassName") '  <<<<<<<< this line error
        Dim ViewId As String =  Jo2.RunMethod("mClassName", Array As Object()) ' <<<<< if I try this, error
    Next
End If

How can extract property from an JavaObject ??

Thanks !!!
Sergio
 

Attachments

  • Immagine.png
    Immagine.png
    14.4 KB · Views: 175
Last edited:
Top