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:
getSSIDList:
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

I get the string representation of the ssid list in the log.
But how do I convert the JavaObject into a B4A data structure?
 

Creideiki

Active Member
Licensed User
Longtime User
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

Creideiki

Active Member
Licensed User
Longtime User
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
Cookies are required to use this site. You must accept them to continue using the site. Learn more…