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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -