从Android开发人员参考:取消()和定期的计划任务
public abstract boolean cancel (boolean mayInterruptIfRunning)
If the task has already started, then the mayInterruptIfRunning parameter
determines whether the thread executing this task should be interrupted in
an attempt to stop the task.
这显然对我来说,谈论仅出现一次的任务时。但不是,当我有周期性的任务时,我想让它完成当前的“任务”,但不能开始新的任务。
是不是可以直接使用那些直接使用的盒子?我认为如果将参数设置为true,它可以在完成之前停止当前任务,并且如果将其更改为false,并且当前有一个任务正在运行,则它不执行任何操作。这是正确的吗?
我将如何实现我想要的?我是否应该以某种方式轮询任务以查找它是否正在运行,并在发现它不是时候取消它?