Android Question Wifi class with code

welu1805

Active Member
Licensed User
Longtime User
In the forum are some Wifi libraries. But I found not one, that was perfect for me. One lib I used, caused trouble in Google Play Store: Your device is not compatible. In the Wifi lib was the android permission MODIFY_PHONE_STATE. My tablet has no phone module. So I decided to write a class with my
desired functions.

' Initializes the object
Initialize

' enable then given network by number in the actual network list
enableNetwork(netID As Int, disableOthers As Boolean) As Boolean

' enable or disable Wi-Fi.
enableWifi(enabled As Boolean) As Boolean

' if found, return networkId
' if not found, Return - 1
' if wifi is not enabled, Return -2
findConfiguredNetwork(AServerName As String) As Int

' Return whether Wi-Fi is enabled or disabled.
isWifiEnabled As Boolean

' if available and suplicantState "COMPLETED" return SSID
' if available and suplicantState <> "COMPLETED" return "not completed"
' if wifi is not enabled, Return "unknown ssid"
returnActSSID As String

' return True, if the given SSID is the current active AP
isAPActive(ServerName As String) As Boolean

' returns a list with all configured networks, separated with ";", mark the active as T, otherwise F
' networkId;SSID;T or F
' if wifi is not enabled, return List is not initialized
returnAllConfiguredNetworks As List

' Gets the Wi-Fi enabled state
' 0 = WIFI_STATE_DISABLING
' 1 = WIFI_STATE_DISABLED
' 2 = WIFI_STATE_ENABLING
' 3 = WIFI_STATE_ENABLED
' 4 = WIFI_STATE_UNKNOWN
returnWifiState As Int

' Required permissions in manifest
'======================================================
' AddPermission("android.permission.ACCESS_WIFI_STATE")
' AddPermission("android.permission.CHANGE_WIFI_STATE")
'======================================================

I already got help in many problems from many other users, therefore I want also to help other programmers. I hope, the attached code is helpful for someone.

You can use the class like you want.

Lutz
 

Attachments

  • clsWifi.bas
    5.2 KB · Views: 140
Last edited:
Top