Android Question How to handle a JavaObject as data?

Creideiki

Active Member
Licensed User
Longtime User
Hi,

I try to read the ssid list (without library).

I got to this point:
[CODE lang="b4x" title="getSSIDList" highlight="7"]Public Sub getSSIDList As List
Dim ssids As List
ssids.Initialize
Dim wifiManager As JavaObject = getWifiManager
Dim jo_ssids As JavaObject = wifiManager.RunMethod("getScanResults", Null)
Log("getSSIDList: " & jo_ssids.RunMethod("toString", Null))
' TODO
Return ssids
End Sub

Private Sub getWifiManager As JavaObject
Dim jo As JavaObject
Return jo.InitializeContext.RunMethod("getSystemService", Array("wifi"))
End Sub
[/CODE]

I get the string representation of the ssid list in the log.
But how do I convert the JavaObject into a B4A data structure?
 
Thank you, that works so far.
Now I have a List with objects of type android.net.wifi.ScanResult. Can I do anything with them?
 
Upvote 0
Yes. And then I can
B4X:
    Dim los As List = jo_ssids
    For Each ssidjo As JavaObject In los
        Dim ssid As String = ssidjo.GetField("SSID")
        Log("SSID = " & ssid)
    Next

Thank you!
 
Upvote 0
Back
Top