【问题标题】:How to get notification when a new device connected to android hotspot新设备连接到android热点时如何获得通知
【发布时间】:2024-01-13 11:55:01
【问题描述】:

我想在设备从热点添加或删除时收到通知。我已经注册了 IntentFilter.addAction() 来获取通知,但是当新设备连接到热点时它不会触发。

IntentFilter intentFilter = new IntentFilter();

intentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);


getActivity().registerReceiver(myReceiver, intentFilter);

【问题讨论】:

  • 我之前问过但没有可能的答案:) 所以 +1

标签: android android-intent android-wifi


【解决方案1】:

您是否尝试过 'getWifiState()' 那么如果结果是:

常数值:0 (0x00000000) --> WIFI_STATE_DISABLING

常量值:1 (0x00000001) --> WIFI_STATE_DISABLED

常量值:2 (0x00000002) --> WIFI_STATE_ENABLING

常数值:3 (0x00000003) --> WIFI_STATE_ENABLED

常数值:4 (0x00000004) --> WIFI_STATE_UNKNOWN

查看其他选项:http://developer.android.com/reference/android/net/wifi/WifiManager.html

如果我帮助了你,你可以在我的回答上打勾,谢谢!

【讨论】: