WiFi getScanResults returns an empty list if GPS is off. (Android 6.0.1)

僤鯓⒐⒋嵵緔 提交于 2019-11-29 21:56:31

问题


i tried to explain the problem in this gif

basically, this test app receives an "RSSI_CHANGED" intent and displays the scan results on the screen.

scan results are always empty unless GPS is enabled.

I guess my question is why?


To access the hardware identifiers of nearby external devices via Bluetooth and Wi-Fi scans, your app must now have the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permissions

I have "ACCESS_COARSE_LOCATION" granted


回答1:


You must declare ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION. A location permission is required because Bluetooth scans can be used to gather information about the location of the user.

This information may come from the user's own devices

So you must give that permission and on the GPS for Bluetooth devices.




回答2:


Google, Apple, Microsoft, et al, build, maintain, and sell databases of Wi-Fi routers and their locations. By requiring you to enable location functionality when scanning nearby WiFi networks, they acquire and update these data.



来源:https://stackoverflow.com/questions/35361064/wifi-getscanresults-returns-an-empty-list-if-gps-is-off-android-6-0-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!