java - Run task after 10 seconds, unless user presses button -
in android app, want schedule task run in 10 seconds, unless user presses specific button. best way this? should use java.util.timer
, java.util.concurrent.scheduledthreadpoolexecutor
or else?
thank in advance.
a handler fit if accessing ui task :
runnable runnable = new runnable() { public void run () { // stuff here } } handler handler = new handler(); handler.postdelayed(runnable, 10000);
in button action :
handler.removecallbacks(runnable);
otherwise, timer
fine.
Comments
Post a Comment