Best Practice to report user location continuously

霸气de小男生 提交于 2020-01-20 15:16:06

问题


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:


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



来源:https://stackoverflow.com/questions/8332819/best-practice-to-report-user-location-continuously

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!