简体   繁体   中英

Scan wifi APs without turn on Wifi? [Android]

Is it possible to scan wifi APs without turn on Wifi? I built an App that scan for wifi APs.. If wifi is disabled the app turn wifi on and off to scan. 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.

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?

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! :)

Is it possible to turn on and off wifi without being "visible" for the user? What do you means by 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.

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.

to on wifi

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

to off 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. 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. 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. 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. This is mostly due to technical limitations and power consumption of mobile phones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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