Skip to content

Instantly share code, notes, and snippets.

@sontqq
Created December 15, 2019 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sontqq/521de73b4ae32cfaf9f6ab4a5051ad2e to your computer and use it in GitHub Desktop.
Save sontqq/521de73b4ae32cfaf9f6ab4a5051ad2e to your computer and use it in GitHub Desktop.
Android Java - How to run repetitive tasks
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
method_call();
}
}, 0, 10000);
android.os.Handler handler = new android.os.Handler();
handler.postDelayed(new Runnable(){
public void run(){
method_call();
handler.postDelayed(this, 10000);
}
}, 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment