简体   繁体   中英

GPS and network location android

I'm creating an app and I've done everything without problem until I've came up with this. I've read a lot on GPS and network location but still I'm a little bit confused. My application will fire itself in the background every X minutes (from 0 to 120 minutes depending on the user) and will get current location (wheter GPS or network I still don't know). I'm aiming for relatively good battery but I need a precision of minimum 100 meters (350 feets) Anything from 5-100 meters accuracy is perfect. Also, if the precision can't be improved then discard the measurement and wait for another X minutes. Any suggestions?

look for the DOP (Dilution Of Precision) value for your GPS fix: it tells you how precise the position is, according to the number of GPS satellites used to compute the position. incidentally, the number of satellites used to compute the position is important.

so, once your application starts, poll the GPS for a position, until the DOP value gets below a given threshold (a DOP of 3.0 is quite precise, around 20 meters). if you don't get such a value in a specified amount of time, then use the best position you received.

almost all GPS chips are now using A-GPS, especially on android, so you get a fix pretty quickly (under 30 seconds). in case your A-GPS informations are out of date (A-GPS files are downloaded through an internet connection), your first fix will take longer: it can take up to 6 minutes get a usable fix when the GPS have no idea where it is located.

so to minimize battery usage: wait for the first fix. if no fix in 6 minutes, shut down the application because you won't have any position. once you have the first fix, poll the GPS for 2 or 3 minutes. if the DOP falls below a threshold (3.0 is a good guess, but try for yourself), stop polling. if the DOP don't fall below the threshold, use the position which had the lowest DOP.

be aware that the longer you wait, the better the precision of the fix, and the DOP depends on the position of all visible satellites, sometimes there is not enough visible satellites or they are not placed optimally to get a precise position.

if the DOP is not available (i don't know the specifics of the Android Location API), the number of satellites used to compute the position may be an imprecise but still useful information (less than 3, drop the position, 3 is awful, more than 4 is average, 10 is quite good).

read more about DOP here . read more about A-GPS here , and about GPS in general here .

of course android is able to locate your device without any GPS signal by using informations from the GSM network or surrounding Wifi networks, but then i can't tell you how to know how precise your position is.

The simplest thing would be to use the Location.getAccuracy() method. On interpreting the result see: How is location accuracy measured in Android?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM