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

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -