Wifi Management

OpenWifiSettings

open wifi setting page in android settings.

public static void OpenWifiSettings()

IsNetworkAvailable

check is network connected

public static bool IsNetworkAvailable()

GetWifiStrength

get wifi strength, the same with name rssi value in android

public static int GetWifiStrength()

RegisterWifiReceiver

register wifi callback, get wifi state/info dynamic

public void RegisterWifiReceiver(OnWifiStateChangeHandler wifiHandler, 
                OnNetworkStateChangeHandler networkStateHandler,
                OnRssiChangeHandler rssiChangeHandler)

Parameter

Description

wifiHandler

callback when wifi state change

networkStateHandler

callback when network state change

rssiChangeHandler

callback when rssi change

UnRegisterConnectionChangeReceiver

unregister wifi callback.

Warning: this method will remove all listeners registered by “RegisterWifiReceiver”

public void UnRegisterConnectionChangeReceiver()

SetWifiEnabled

enable/disable wifi, enable wifi do not mean wifi is connected.

public bool SetWifiEnabled(bool enable)

Parameter

Description

enable

  • true to enable wifi

  • false to disable wifi

GetWifiState

return current wifi state, exp: 0 for netStateConnecting, 1 for netStateConnected, etc.

public int GetWifiState()

IsWifiEnable

if wifi is enable state

public bool IsWifiEnable()

GetConfiguredWifi

Return a list of all the networks configured for the current foreground user. contains params: networkId/SSID/BSSID/priority/allowedProtocols/allowedKeyManagement /allowedAuthAlgorithms/allowedPairwiseCiphers/allowedGroupCiphers

public string GetConfiguredWifi()

GetConnectedWifiSSID

Return ssid about the current Wifi connection, if any is active

public string GetConnectedWifiSSID()

StartScanWifi

Request a scan for access points. Returns immediately. The availability of the results is made known later by means of an asynchronous event sent on completion of the scan.

public bool StartScanWifi()

GetScanResult

Request the results of the latest access point scan.

public string GetScanResult()

GetMacAddress

Get mac address if wifi is connected

public string GetMacAddress()

ConnectWifi

connect Wifi by wifi name (ssid) and password

public bool ConnectWifi(string ssid, string password, int wificipherType)

Parameter

Description

ssid

wifi name

password

wifi password

wificipherType

wifi cipher type, such as web

ConnectStaticIpWifi

connect static ip wifi

public bool ConnectStaticIpWifi(string ssid, string password, int wificipherType,
                           int prefixLength, string ipAddress, string gateway, string dns)

Parameter

Description

ssid

wifi name

password

wifi password

wificipherType

wifi cipher type, such as wep

prefixLength

ip prefix length

ipAddress

ip address

gateway

dns1 gateway

dns

dns

DisconnectWifi

disconnect wifi

public bool DisconnectWifi()

RemoveWifiBySsid

remove wifi by ssid

public void RemoveWifiBySsid(string ssid)

Parameter

Description

ssid

wifi name

Last updated