最佳实践,不断举报用户位置 [英] Best Practice to report user location continuously

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

问题描述

我设计一个应用程序,服务器端应用程序需要不断了解用户的位置。我想创建一个在后台运行,并不断地查询用户位置在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依旧参数,以避免消耗电池。 <一href="http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates%28java.lang.String,%20long,%20float,%20android.app.PendingIntent%29"相对=nofollow>文档

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

关于你的评论,你必须要对你的服务粘性: <一href="http://developer.android.com/reference/android/app/Service.html#onStartCommand%28android.content.Intent,%20int,%20int%29"相对=nofollow>文档

Regarding your comment you have to start your service sticky: Documentation

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

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