Sub Process_Globals
Private wifiManager As WifiManager
End Sub
Sub Globals
Private ListView1 As ListView
Private btnScan As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
wifiManager.Initialize("WifiManager")
If PermissionManager.CheckPermission("android.permission.ACCESS_FINE_LOCATION") = False Then
PermissionManager.RequestPermission("android.permission.ACCESS_FINE_LOCATION")
End If
ListView1.SingleLineLayout.Label.TextSize = 14
ListView1.SingleLineLayout.Label.TextColor = Colors.Black
btnScan.Initialize("btnScan")
btnScan.Text = "Scan Wi-Fi"
Activity.AddView(btnScan, 10dip, 10dip, 100dip, 50dip)
ListView1.Initialize("ListView1")
Activity.AddView(ListView1, 10dip, 70dip, 300dip, 400dip)
End Sub
Sub btnScan_Click
' Check if Wi-Fi is enabled and start scan
If wifiManager.WifiEnabled = False Then
wifiManager.SetWifiEnabled(True)
End If
wifiManager.StartScan
End Sub
Sub WifiManager_ScanResultsAvailable
Dim results As List = wifiManager.GetScanResults
ListView1.Clear
For Each result As Map In results
Dim ssid As String = result.Get("SSID")
Dim bssid As String = result.Get("BSSID")
ListView1.AddSingleLine(ssid & " (" & bssid & ")")
Next
End Sub
Sub Activity_PermissionResult(Permission As String, Result As Boolean)
If Result Then
ToastMessageShow("Permission granted", False)
Else
ToastMessageShow("Permission denied", False)
End If
End Sub