简体   繁体   English

GPS定位跟踪

[英]GPS Location Tracking

I would like to implement GPS Tracking service. 我想实施GPS跟踪服务。 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. 当用户离家一英里远时,我将在每个预定义的时间间隔内以其地图位置发送SMS消息。

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? 此外,GPS的精确度如何,以及获得距离的最佳做法是什么?

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. 根据我的经验,始终使用GPS跟踪用户何时离开家乡不是一个好主意,因为它会立即消耗电池电量。 I ended up learning the home location by looking at the cell tower IDs over night (assuming the user is at home then). 我最终通过夜间查看手机信号塔ID(假设用户当时在家中)来了解家庭位置。 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. 如果您遵循此策略,则可以在用户连接到新的手机信号塔并节省大量电池的情况下启动GPS。

Regarding accuracy. 关于准确性。 You can get the accuracy provided with each Android.Location object. 您可以获得每个Android.Location对象提供的准确性。 If you are outside, this is usually 5 or 10 meters. 如果您在外面,通常是5或10米。 But be aware that there is only an 68% chance this value is correct, according to the documentation : 但请注意,根据文档 ,这个值只有68%的可能性是正确的:

We define accuracy as the radius of 68% confidence. 我们将准确度定义为68%置信度的半径。 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. 换句话说,如果您绘制一个以该位置的纬度和经度为中心且半径等于精度的圆,则真实位置在该圆内的可能性为68%。

Be carefull, the getLastKnownLocation method will not necessary return the user home position. 请注意,getLastKnownLocation方法将不必返回用户原始位置。 You shoud rather get the current position. 您应该宁愿获得当前职位。 Most of the time, getLastKnownLocation is used to get a location quickly (avoiding heavy background work). 大多数情况下,getLastKnownLocation用于快速获取位置(避免繁重的后台工作)。

GPS accuracy depends on many factors: GPS精度取决于许多因素:

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 这里是一个很好的链接: http : //developer.android.com/guide/topics/location/strategies.html

You will learn a lot with that. 您将学到很多东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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