开发者

Multiple timerTask

开发者 https://www.devze.com 2023-01-31 23:27 出处:网络
In My app I want to do some operations on every 3mins, 5mins, 10 mins. In android is there any API to do it in single开发者_StackOverflow社区 Timer/thread. What is the best way to that ? The proper wa

In My app I want to do some operations on every 3mins, 5mins, 10 mins. In android is there any API to do it in single开发者_StackOverflow社区 Timer/thread. What is the best way to that ?


The proper way to create Timers in Android is to use Handler, as suggested here. You could create one Handler task for every interval you need.

One thing to notice is that if you need long intervals (like 3 or 5 minutes you've mentioned), your application may not running for so long. In that a case you can use and AlarmManager.

0

精彩评论

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

关注公众号