Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中实现类似TimerTask的最佳方法_Android_Timer_Resume_Timertask - Fatal编程技术网

在Android中实现类似TimerTask的最佳方法

在Android中实现类似TimerTask的最佳方法,android,timer,resume,timertask,Android,Timer,Resume,Timertask,我知道这个问题有点难回答,但我还没有找到我具体问题的答案 我有几个组件使用TimerTask,我需要暂停并在之后继续 最好的方法是什么?(即使不使用定时器/定时器任务系统) 提前谢谢 JQCorreia你想做什么?TimerTask实际上非常古老,从1.3开始就是java的一部分。较新的首选方法是使用executor服务。看看如何使用。下面是另一个答案类似的问题 我有几个组件使用TimerTask,我需要暂停并在之后继续。 最好的方法是什么 使用。有了它,您可以发布一个Runnable以使用运行

我知道这个问题有点难回答,但我还没有找到我具体问题的答案

我有几个组件使用
TimerTask
,我需要暂停并在之后继续

最好的方法是什么?(即使不使用定时器/定时器任务系统)

提前谢谢
JQCorreia

你想做什么?TimerTask实际上非常古老,从1.3开始就是java的一部分。较新的首选方法是使用executor服务。看看如何使用。下面是另一个答案类似的问题

我有几个组件使用TimerTask,我需要暂停并在之后继续。 最好的方法是什么

使用。有了它,您可以发布一个
Runnable
以使用运行,并通过使用删除它。API中还有一些方法可以使
可运行
在指定的延迟后执行


结合这两种方法在应用程序中实现暂停/恢复功能。

谢谢!我已经使用处理程序消息实现了一个简单的计时器,该处理程序消息执行一个runnable。简单干净,相当容易。