开发者

how to use START_NOT_STICKY

I am trying to run a service that polls the server every ten seconds and broadcasts the intent. I tried using Thread.sleep(10000) but that dint work开发者_StackOverflow社区. I found out about this START_NOT_STICKY constant used in the service. But I am unable to figure how do I use it. Can someone please help.

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        handleStart(intent, startId);
        return START_NOT_STICKY;
    }


I am trying to run a service that polls the server every ten seconds

Please make this user-configurable, including supporting "never poll".

I tried using Thread.sleep(10000) but that dint work.

I would recommend the use of AlarmManager and an IntentService, so your service code can shut down and get out of RAM between polls. That is not a great solution for running code every 10 seconds, but I am hopeful that your users will reconfigure your app to poll at a more graceful pace, since polling a server every 10 seconds will be expensive in terms of battery and bandwidth usage.

I found out about this START_NOT_STICKY constant used in the service.

This does not have much to do with polling a server every 10 seconds.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜