开发者

Android: Force use of Wi-Fi as Location Provider

开发者 https://www.devze.com 2023-01-26 06:48 出处:网络
As I understand it, I have three location providers to choose from: GPS, Network and Passive. I would like to obtain my location by detecting the Wi-Fi network I\'m connected to, I believe both Cell

As I understand it, I have three location providers to choose from: GPS, Network and Passive.

I would like to obtain my location by detecting the Wi-Fi network I'm connected to, I believe both Cell Triangulation and Wi-Fi location determination is covered under the Network provider.

However, despite being connected to a Wi-Fi access point, my program always seems to use cell triangulation rather than Wi-Fi to determine my location (assumed based on the huge inaccuracy of the returned coordinates).

It doesn't look like there's any way to force the use of Wi-Fi only? How does Androi开发者_StackOverflowd decide when to use Wi-Fi over cell triangulation?


I think it uses wifi when the wifi information scanned from the wifi chipser matches data the remote Google database (I don't know the coverage of this database, but it should include all cities that have StreetView). Else it uses the far less accurate cell triangulation.

To check which kind is used, you might try LocationProvider.requireCell() (haven't tested it...)

0

精彩评论

暂无评论...
验证码 换一张
取 消