問(wèn)題描述
我們知道Android中有兩種定位模式:GPS和網(wǎng)絡(luò).如果我們使用網(wǎng)絡(luò),那么Android可以使用WIFI或2G/3G基站定位.如果沒(méi)有 GPS,我們可以簡(jiǎn)單地使用 LocationManager.NETWORK_PROVIDER 來(lái)獲取位置數(shù)據(jù).但是我們?cè)趺粗滥J绞荳IFI還是2G/3G基站呢?Android 沒(méi)有為 WIFI 和信號(hào)塔提供單獨(dú)的提供程序.
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.
我想到了一個(gè)方法.但我不確定它是否正確.請(qǐng)查看并發(fā)表意見(jiàn):
I have thought a method. But I am not sure whether it is correct. Please review and give comments:
- 查看能否獲取WIFI熱點(diǎn)列表.如果列表中沒(méi)有任何內(nèi)容,則必須使用手機(jī)信號(hào)塔.
- 如果有一些WIFI熱點(diǎn),并且精度很高(<=100m),那么很可能使用了WIFI.如果準(zhǔn)確率低,是否還在使用手機(jī)信號(hào)塔?
據(jù)我了解,WIFI定位的準(zhǔn)確率是比較高的.但它的準(zhǔn)確度的正常范圍是多少?另一個(gè)問(wèn)題,Android 是否同時(shí)使用 WIFI 和信號(hào)塔?如果是這樣,那么在我的應(yīng)用程序中,我可以認(rèn)為它使用的是 WIFI,而不是手機(jī)信號(hào)塔.
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 并沒(méi)有明確給出確定如何計(jì)算網(wǎng)絡(luò)位置的方法.網(wǎng)絡(luò)提供商的原則是收集設(shè)備上的所有相關(guān)數(shù)據(jù),然后將其全部發(fā)送到谷歌服務(wù)器,在那里計(jì)算您的位置并將其發(fā)送回您.我不確定,但網(wǎng)絡(luò)位置也可能使用加速度計(jì)/陀螺儀/羅盤(pán)數(shù)據(jù)來(lái)提高位置的準(zhǔn)確性,尤其是當(dāng)您連續(xù)計(jì)算位置時(shí).所以我相信它可以同時(shí)使用手機(jī)信號(hào)塔和 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.
您的準(zhǔn)確度方法應(yīng)該適用于大多數(shù)情況,但并非 100% 可靠.
Your accuracy method should work in most cases, but is not 100% reliable.
另一種可能性是關(guān)閉 wifi,計(jì)算第一個(gè)位置修復(fù),然后再次打開(kāi)并再次嘗試.通過(guò)比較這兩個(gè)位置及其準(zhǔn)確度估計(jì),您大概可以猜出 wifi 對(duì)您當(dāng)前位置的定位引擎的影響.
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.
出于好奇,你為什么需要這個(gè)?
Out of curiosity, why do you need this for?
這篇關(guān)于Android中如何知道定位模式是WIFI還是2G/3G基站?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!