我正在设计一个应用程序,其中服务器端的应用程序需要持续了解用户位置。我正在考虑创建一个在后台运行并持续查询用户位置并将结果发送到后端服务器中的应用程序的 Android 服务。但是,我想知道这是否是节省电池的最佳方法。例如,在iOS中,有一个称为“重大更改”的东西来达到这样的目的,Android是否有类似的东西。
I'm designing an application where application in server side need to be continuously aware of user location. I'm thinking to create an Android service that run in the background and continuously query user location and send the result to an application in the backend server. However, I wonder if this is the best approach in terms of battery saving. For example, in iOS, there is something called "Significant-Change" to serve such purpose, does Android have similar thing.
发布评论
评论(1)
我建议创建一个仅使用 NETWORK_PROVIDER 和 PASSIVE_PROVIDER 的后台服务。您可以使用 minTime 和 minDistance 参数来避免耗尽电池电量。 文档
Reto 写了一篇关于获取用户位置的精彩文章
http://android-developers.blogspot.com/ 2011/06/deep-dive-into-location.html
关于您的评论,您必须启动您的服务粘性:
文档< /a>
I suggest to create a background Service which just uses the NETWORK_PROVIDER and the PASSIVE_PROVIDER. You can use the minTime and the minDistance parameter to avoid draining the battery. Documentation
And Reto wrote a great post about obtaining users location
http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html
Regarding your comment you have to start your service sticky:
Documentation