Android Question need an application that detect all Wi-fi available

TILogistic

Expert
Licensed User
Longtime User
?
test:
B4X:
   Sub Process_Globals
       Private wifiManager As JavaObject
       Private wifiList As List
   End Sub

   Sub Globals

   End Sub

   Sub Activity_Create(FirstTime As Boolean)
       ' Initialize the Wi-Fi Manager
       wifiManager.InitializeContext
       wifiManager = wifiManager.Initialize("android.net.wifi.WifiManager")
     
       ' Enable Wi-Fi if it's not already enabled
       If wifiManager.RunMethod("isWifiEnabled", Null) = False Then
           wifiManager.RunMethod("setWifiEnabled", Array(True))
       End If
     
       ' Scan for available Wi-Fi networks
       wifiManager.RunMethod("startScan", Null)
     
       ' Get the list of Wi-Fi networks
       wifiList = wifiManager.RunMethod("getScanResults", Null)
     
       ' Process the results
       For Each result As JavaObject In wifiList
           Dim ssid As String = result.GetField("SSID")
           Dim bssid As String = result.GetField("BSSID")
           Dim level As Integer = result.GetField("level")
         
           Log("SSID: " & ssid & ", BSSID: " & bssid & ", Level: " & level)
       Next
   End Sub

Ref:
 
Upvote 0

jkhazraji

Active Member
Licensed User
Longtime User
You need a receiver module not a class to perform "android.net.wifi.WifiManager"
 
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
?
test:
B4X:
   Sub Process_Globals
       Private wifiManager As JavaObject
       Private wifiList As List
   End Sub

   Sub Globals

   End Sub

   Sub Activity_Create(FirstTime As Boolean)
       ' Initialize the Wi-Fi Manager
       wifiManager.InitializeContext
       wifiManager = wifiManager.Initialize("android.net.wifi.WifiManager")
    
       ' Enable Wi-Fi if it's not already enabled
       If wifiManager.RunMethod("isWifiEnabled", Null) = False Then
           wifiManager.RunMethod("setWifiEnabled", Array(True))
       End If
    
       ' Scan for available Wi-Fi networks
       wifiManager.RunMethod("startScan", Null)
    
       ' Get the list of Wi-Fi networks
       wifiList = wifiManager.RunMethod("getScanResults", Null)
    
       ' Process the results
       For Each result As JavaObject In wifiList
           Dim ssid As String = result.GetField("SSID")
           Dim bssid As String = result.GetField("BSSID")
           Dim level As Integer = result.GetField("level")
        
           Log("SSID: " & ssid & ", BSSID: " & bssid & ", Level: " & level)
       Next
   End Sub

Ref:
Many thanks for your support,
I just have two errors as in attached image:

1730415921181.png


1730415831603.png


How to solve them, please.
Best regards
 
Upvote 0
Top