问题
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