持续报告用户位置的最佳实践 [英] Best Practice to report user location continuously

查看:22
本文介绍了持续报告用户位置的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个应用程序,其中服务器端的应用程序需要持续了解用户位置.我正在考虑创建一个在后台运行并不断查询用户位置并将结果发送到后端服务器中的应用程序的 Android 服务.但是,我想知道这是否是节省电池电量的最佳方法.例如,在iOS中,有一个叫做Significant-Change"的东西来服务这个目的,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.

推荐答案

我建议创建一个只使用 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

Reto 写了一篇关于获取用户位置的好文章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

这篇关于持续报告用户位置的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆