开发者

checking server updates using services after user login

hi all i need to start a service when user clicks login button , this s开发者_运维知识库ervice have to check the server updates for each five minutes,and when the user log off this service have to stop. can any body tell me how could i achieve this.if possible help me with sample codings.thank you in advance


There are tons of examples available for service, the official android site has it too http://developer.android.com/reference/android/app/Service.html

My suggestion is that you use a alarm service to invoke your service in the specified interval. You can terminate it when you too as well. Alarm Manager details are here. But note that The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use Handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜