简体   繁体   中英

GPS Location Tracking

I would like to implement GPS Tracking service. After a search on the web I'm still a bit confused on the best way to practice this feature.

I want to start following the user when he gets a mile away from his home.

I thought that the app will be installed at user's home and using:

locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

I'll get the user's coordinates and compare it with changing coordinates as he travels. When the user gets away a mile from his home I'll send SMS messages with his maps location every predefined time interval.

I was wondering if there is someone who done something similar before and can recommend a best practice for this task.

Also, how accurate the GPS can be, and what might be the best practice to get distance?

Thanks in advance.

From my experience it is not a good idea to use GPS all the time to track when a user departs from his home location because it burns the battery in no time. I ended up learning the home location by looking at the cell tower IDs over night (assuming the user is at home then). If you reach a certain level of confidence that you know the user's home location you can ask him something like "Are you at home right now?" to be completely sure (although this is somehow creepy for many users).

If you follow this strategy you can start the GPS if the user connects to a new cell tower and save a lot of battery.

Regarding accuracy. You can get the accuracy provided with each Android.Location object. If you are outside, this is usually 5 or 10 meters. But be aware that there is only an 68% chance this value is correct, according to the documentation :

We define accuracy as the radius of 68% confidence. In other words, if you draw a circle centered at this location's latitude and longitude, and with a radius equal to the accuracy, then there is a 68% probability that the true location is inside the circle.

Be carefull, the getLastKnownLocation method will not necessary return the user home position. You shoud rather get the current position. Most of the time, getLastKnownLocation is used to get a location quickly (avoiding heavy background work).

GPS accuracy depends on many factors:

Weather, quality of the chip, field, ...

But, most of the time, it's more accurate that the network provider.

Here a very good link : http://developer.android.com/guide/topics/location/strategies.html

You will learn a lot with that.

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