Fetching user location in background and uploading it to web server (trying to avoid using Service)

空扰寡人 提交于 2019-12-25 00:34:04

问题


My application is based on Google Map and Location which includes client-server communications. Apart from all that, periodically I want to update the user location to web server. I gave thought myself and ended up with below two scenarios,

First One : I use Service class to fetch user location periodically (considering 2-3 hours once) and update to server. Ideally I want to avoid this! Because just to upload user location its not good to run the service all the time is what I feel.

Second Thought : I can use IntentService to fetch the user location periodically (considering same 2-3 hours) and update to web server. Here IntentService will be invoked by an AlarmManager. That is every 2-3 hours once alarm manager will start IntentService.

But I feel using AlarmManager for 2-3 hours once is not a good idea too.

I want to understand which one will be efficient and more relevant! Whether this scenario can be implemented in any other approach? If so help me do it!

Thanks in advance...

来源:https://stackoverflow.com/questions/34242242/fetching-user-location-in-background-and-uploading-it-to-web-server-trying-to-a

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