简体   繁体   English

在不打开Wifi的情况下扫描wifi AP? [Android]

[英]Scan wifi APs without turn on Wifi? [Android]

Is it possible to scan wifi APs without turn on Wifi? 是否可以在不打开Wifi的情况下扫描wifi AP? I built an App that scan for wifi APs.. If wifi is disabled the app turn wifi on and off to scan. 我构建了一个扫描wifi AP的应用程序。如果禁用了wifi,则该应用程序会打开和关闭wifi进行扫描。 But I noticed a problem, when I was using my Smartphone as an Access Point and when the app turned on wifi my smartphone stopped being an Access Point. 但是我注意到一个问题,当我将智能手机用作接入点时,当应用程序打开wifi时,我的智能手机不再是接入点。

If this is not possible and if there is no other way to do this I've to accept this "problem".. 如果这是不可能的,并且如果没有其他方法可以做到,那么我必须接受这个“问题”。

Curiosity: Is it possible to turn on and off wifi without being "visible" for the user? 好奇心: 是否可以在用户不可见的情况下打开和关闭wifi?

Scanning Wifi Access Points without your wifi being on is like taking picture without running your camera app or not removing your camera lens cap! 在没有开启wifi的情况下扫描Wifi接入点就像在不运行相机应用程序或不卸下相机镜头盖的情况下拍照! :) :)

Is it possible to turn on and off wifi without being "visible" for the user? What do you means by being visible . being visible意味着什么。 If your wifi is configured to acts as a AP, you should create a hidden AP, if not, you're not AP and you're not visible. 如果您的wifi被配置为充当AP,则应创建一个隐藏的AP,否则,您应该不是AP,并且不可见。

I'm just guessing a solution that might works, When your app turned on wifi, just wait till your wifi start as a AP and then try scanning. 我只是在猜测一个可行的解决方案,当您的应用程序打开wifi时,只需等到wifi作为AP启动后再尝试扫描即可。

to on wifi 到wifi

WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
wifiManager.setWifiEnabled(true);

to off Wifi 关闭Wifi

 WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
 wifiManager.setWifiEnabled(false);

Even though in latest Android version ( KitKat ) there is an option for Scan-Only mode, it is impossible to obtain scan results with disabled WiFi. 即使在最新的Android版本( KitKat )中提供了“ 仅扫描”模式选项,也无法通过禁用WiFi来获取扫描结果。 There is no way to make this totally hidden from user perspective. 从用户的角度来看,没有办法将其完全隐藏。 Howewer, with Scan-Only mode getting the scan results is basically an instant operation (since they are already available), so it would be hardly noticeable. Howewer在仅扫描模式下获取扫描结果基本上是即时操作(因为它们已经可用),因此几乎不会引起注意。 Please note, this mode can be disabled. 请注意,可以禁用此模式。

So, on your place I would just do the same thing: turn WiFi on, get scan results, turn WiFi off. 因此,在您的位置上,我会做同样的事情:打开WiFi,获取扫描结果,关闭WiFi。 Safe, convenient, compatible. 安全,方便,兼容。

As to the use case with AP (so called SoftAP ) and WiFi (so called Station ) at the same time - while working as WiFi engineer for one of the major Android phone OEM's, I'm not aware of any Android WiFi solution that is capable of running both SoftAP and Station at the same time. 至于同时使用AP(所谓的SoftAP )和WiFi(所谓的Station )的用例-在为一家主要的Android手机OEM的WiFi工程师工作时,我不知道有哪个Android WiFi解决方案能够同时运行SoftAPStation This is mostly due to technical limitations and power consumption of mobile phones. 这主要是由于技术限制和移动电话的功耗。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM