How to get notified when a new device connects to an Android access point

I want to receive a notification when a device adds or removes from hotspot.I registered IntentFilter.addAction () to receive notifications, but did not start it when a new device is connected to an access point.

IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); getActivity().registerReceiver(myReceiver, intentFilter); 
+4
source share
1 answer

You tried "getWifiState ()", and if the result:

Constant value: 0 (0x00000000) β†’ WIFI_STATE_DISABLING

Constant value: 1 (0x00000001) β†’ WIFI_STATE_DISABLED

Constant value: 2 (0x00000002) β†’ WIFI_STATE_ENABLING

Constant value: 3 (0x00000003) β†’ WIFI_STATE_ENABLED

Constant value: 4 (0x00000004) β†’ WIFI_STATE_UNKNOWN

For other options check here: http://developer.android.com/reference/android/net/wifi/WifiManager.html

If that's all you can just check for my answer, if I could help you, thanks!

0
source

Source: https://habr.com/ru/post/1494046/


All Articles