Android Question read data from a JavaObject array

Pesciolina

Active Member
Licensed User
Longtime User
how can I read the tagID field ??

Thanks
Marco

B4X:
Sub onCAENRFIDNotifyTag_Event (MethodName As String, Args() As Object) As Object
    Dim results As JavaObject = Args(0)
    Dim nTag As Int
            
    Try
        
        Dim CAENRFIDNotifyList As List = results.RunMethod("getData",Null)
        For Each CAENRFIDNotify As JavaObject In CAENRFIDNotifyList
            'Todo something with the JavaObject CAENRFIDNotify'
            nTag = nTag + 1
            Log("Number of Tags received: " & nTag)
            
        Next
        
        Return Null
        
    Catch
        Return Null
        Log(LastException)
    End Try
    
End Sub

1585515419059.png
 
speaking for myself, it would be much easier if you could post the actual json string or the url where i can get it myself. i know we have a json pretty print, but it's not something i use.
 
Upvote 0
the data come from an RDIF reader
I took another small step
it goes wrong when I assign the index 0


B4X:
Dim TagIdArray As List = CAENRFIDNotify.RunMethod("getTagID", Null)
            
            Dim TagID_0 As Byte
            TagID_0 = TagIdArray.Get(0)

1585524813329.png
 
Upvote 0
sorry, i misread javaobject array for json array. beyond my realm of interest, but in looking at the java code, it seems like your TagIdArray list is not a list of byte. have you looked at the source (https://github.com/Maurizio-M/app-r...m/radio6ense/radioScan/InventoryActivity.java)?

you say "it goes wrong", but you didn't say if you got an error. did you? what was it? you might want to wrap your get() call in a try/catch block, and if you get an error, see what it is. i think your "Dim TagID_0 As Byte" declaration should be another (java)object. the java code itself, seems relatively clear enough for someone familiar with CAENRFIDN, which, regrettably, excludes me. sorry.
 
Upvote 0
jordicp working late tonight!
 
Upvote 0
like i say, i thought it was about json. but i definitely defer to the master in device electronics. carry on!
 
Upvote 0
yeah, according to the java source, tagID is an array of Byte, so just step through it 0 to array.length - 1
 
Upvote 0
Back
Top