我有一个使用CountDownTimer计数低于10如何暂停该计时器,当活动已不再是重点,比如如果用户接到一通电话什么的,然后恢复计时器,当用户进入一个活动回活动?这甚至可能?
I have an activity that uses a CountDownTimer that counts down from 10. How do I pause that timer when the activity is no longer in focus, like if the user get a call or something, then resume the timer when the user goes back to the activity? Is this even possible?
我想补充一些东西到onTick处理程序,以节省定时器的进步类(毫秒数左)。
I would add something to the onTick handler to save the progress of the timer in your class (number of milliseconds left).
在的onPause()方法,该活动调用取消()的定时器。
In the onPause() method for the activity call cancel() on the timer.
在onResume()方法的创建活动还剩下的毫秒数保存一个新的计时器。
In the onResume() method for the activity create a new timer with the saved number of milliseconds left.
上一篇:机器人 - javah的没有找到我的课我的、没有找到、机器人、javah
下一篇:修订2:如何从一个后台服务/线程的数据传递到比创建的后台服务MainActivity其他活动后台、线程、数据、MainActivity