最佳实践,不断举报用户位置位置、用户

2023-09-05 07:19:32 作者:一句君无戏言

我设计一个应用程序,服务器端应用程序需要不断了解用户的位置。我想创建一个在后台运行,并不断地查询用户位置在Android的服务并将结果发送到后端服务器的应用程序。但是,我不知道这是否是在节电方面的最佳方法。例如,在iOS系统中,有一种叫做显着,改变以服务这样的目的,确实安卓也有类似的事情。

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.

推荐答案

我建议创建一个只使用NETWORK_PROVIDER和PASSIVE_PROVIDER后台服务。您可以使用minTime和minDistance依旧参数,以避免消耗电池。 文档

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

和雷托写了一篇关于获取用户的位置伟大的职位 http://android-developers.blogspot.com/2011 /06/deep-dive-into-location.html

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