Android - 如何知道操作系统何时检测到附近的WiFi路由器? [英] Android - How to know when the OS detects nearby WiFi routers?

查看:140
本文介绍了Android - 如何知道操作系统何时检测到附近的WiFi路由器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android操作系统定期扫描可用的WiFi路由器。发生这种情况时是否有办法得到通知?我正在寻找 BroadcastReceiver 触发器,但找不到任何。网络状态更改不适用于此方案。我试图在室内使用WiFi路由器检索用户的位置。任何想法如何做到这一点?

解决方案

我会简短地讲述故事,如果没有这些,你将无法做到使用您自己的wifimanager.startscan()实现 - 为了扫描WiFi AP,在解决方案中您需要使用意图过滤器WifiManager.SCAN_RESULTS_AVAILABLE_ACTION。
在这种方法中,您将能够通过使用getScanResults()方法获得所有WiFi AP列表的广播。为了重复做它,请考虑使用处理程序或线程。


Android OS periodically scans for available WiFi routers. Is there a way to get notified when this happens? I was searching for a BroadcastReceiver trigger but could not find any. Network state change doesn't work for this scenario. I'm trying to retrieve user's location using WiFi routers in indoor locations. Any idea how this could be done?

解决方案

I'll make the story short, You will not be able to do it without using your own implementation of wifimanager.startscan() - in order to scan WiFi AP, in the solution you need to use the intent filter WifiManager.SCAN_RESULTS_AVAILABLE_ACTION. In this approach you will be able to get a broadcast with a list of all WiFi AP by using getScanResults() method. in order to do it repeatedly please consider to use handler or thread.

这篇关于Android - 如何知道操作系统何时检测到附近的WiFi路由器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆