android timer swing

2019-07-10 02:04发布

I need to create a Timer to update the UI at regular intervals. But the Swing Timer class is not available on Android. How can I work around this problem ? (I would avoid creating threads and then use the Timer class from java.util package)

标签: android timer
2条回答
beautiful°
2楼-- · 2019-07-10 02:31

You could use a Handler and the postAtTime() method or the postDelayed() method. This will allow you to schedule a Runnable to be executed at some point in the future.

查看更多
来,给爷笑一个
3楼-- · 2019-07-10 02:33

Well, for your problem Handler class would suffice(+1 to Dave :)).
FYI, there are other classes namely AlarmManager, Timer & TimerTask that can help with timing the runs of your code.

查看更多
登录 后发表回答