Does Android provide a notification of being in vicinity of a new Wifi Network? Whether the device is configured to connect to that wifi network depends on whether the device has the wifi configuration set for that particular wifi network, but is it possible to get notification whenever entering any new wifi network?
I saw the WifiManager class but the states inside the class do not seem to achieve what I am trying to do. Any ideas?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Use a
BroadcastReceiver
registered to receive intents with action:WifiManager.NETWORK_STATE_CHANGED_ACTION
.In this BroadcastReceiver, you can extract a NetworkInfo object from the intent:
Then process
ni.getState()
to check connections/disconnections from wifi networks.Is this what you were looking for?
Edit after answer
So if you want to know which wifi networks are available, use WifiManager.getScanResults() This gives you the list of nearby access points in
Scanresult
objects. Those contain the SSID and BSSID of the access points, which are respectively their network name and mac address.You can get this information asynchronously by using a
BroadcastReceiver
registered to receive intents with actionWifiManager.SCAN_RESULTS_AVAILABLE_ACTION
. Then you will be notified each time the system performs a wifi scan, and you can check if a new SSID (i.e. network name) has appeared since the last scan.And finally if you wish to scan more often than the system does by default, you can trigger wifi scans yourself using
WifiManager.startScan()
.