问题描述
我们知道Android中有两种定位模式:GPS和网络.如果我们使用网络,那么Android可以使用WIFI或2G/3G基站定位.如果没有 GPS,我们可以简单地使用 LocationManager.NETWORK_PROVIDER 来获取位置数据.但是我们怎么知道模式是WIFI还是2G/3G基站呢?Android 没有为 WIFI 和信号塔提供单独的提供程序.
We know there are two positioning mode in Android: GPS and network. If we use network, then Android can use WIFI or 2G/3G cell tower to position. Without GPS, we can simply use LocationManager.NETWORK_PROVIDER to get the location data. But how can we know the mode is WIFI or 2G/3G cell tower exactly? Android doesn't provide separate providers for WIFI and cell tower.
我想到了一个方法.但我不确定它是否正确.请查看并发表意见:
I have thought a method. But I am not sure whether it is correct. Please review and give comments:
- 查看能否获取WIFI热点列表.如果列表中没有任何内容,则必须使用手机信号塔.
- 如果有一些WIFI热点,并且精度很高(<=100m),那么很可能使用了WIFI.如果准确率低,是否还在使用手机信号塔?
据我了解,WIFI定位的准确率是比较高的.但它的准确度的正常范围是多少?另一个问题,Android 是否同时使用 WIFI 和信号塔?如果是这样,那么在我的应用程序中,我可以认为它使用的是 WIFI,而不是手机信号塔.
In my understanding, the accuracy of WIFI positioning is relatively high. But what's the normal range of the accuracy for it? Another question, does Android use WIFI and cell tower at the same time? If it does, then in my application, I can think it use WIFI, not cell tower.
谢谢!
推荐答案
这是正确的,Android 并没有明确给出确定如何计算网络位置的方法.网络提供商的原则是收集设备上的所有相关数据,然后将其全部发送到谷歌服务器,在那里计算您的位置并将其发送回您.我不确定,但网络位置也可能使用加速度计/陀螺仪/罗盘数据来提高位置的准确性,尤其是当您连续计算位置时.所以我相信它可以同时使用手机信号塔和 Wifi 信息.
This is correct, Android does not explicitely give a way to determine how the network location is computed. The principle of the network provider is to collect all the relevant data on the device, and then send it all to the Google servers, where your location is computed and sent back to you. I am not sure, but the network location might also use the accelerometer/gyro/compass data to improve the accuracy of the location, especially when you compute your location continuously. So I believe it can use simultaneously cell tower and Wifi info.
您的准确度方法应该适用于大多数情况,但并非 100% 可靠.
Your accuracy method should work in most cases, but is not 100% reliable.
另一种可能性是关闭 wifi,计算第一个位置修复,然后再次打开并再次尝试.通过比较这两个位置及其准确度估计,您大概可以猜出 wifi 对您当前位置的定位引擎的影响.
Another possibility is to turn the wifi off, compute a first location fix, then turn it on again and give it another try. by comparing the two locations and their accuracy estimates, you can probably guess the influence of wifi on the location engine at your current location.
出于好奇,你为什么需要这个?
Out of curiosity, why do you need this for?
这篇关于Android中如何知道定位模式是WIFI还是2G/3G基站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!