Efficient Background service for tracking user location

吃可爱长大的小学妹 提交于 2019-12-20 09:46:13

问题


I am developing a small android application in which I want to have Geolocation functionality. What I want to code is one service which gives the updated location of a user whether they are using my application or not.

I know that if I am continuously checking the user's location it will drain the battery of the device, so I want good solution for that. For example, to give me updates every 5 or 10 minutes. I have read about this question a lot but I wanted to get one good solution.

I read this page and it's a good solution if the user is using my application but if the user not using my application then what should I do? How do I solve this challenge?


回答1:


Previously i have developed such kind of application. with respect to your requirement, you will be require following APIs from Android.

  • Location ( for Lat-lon information )
  • AlarmManager ( to schedule an event to fetch lat-lon details on regular basis & upload data to remote server )
  • Http ( an API to send lat-lon details to remote server )
  • Android Service ( will allow to work in background )
  • BroadcastReceiver ( additional , if you wan to start your application automatically on device boot )


来源:https://stackoverflow.com/questions/15714964/efficient-background-service-for-tracking-user-location

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