Skip to content

Instantly share code, notes, and snippets.

@japharr
Created February 25, 2017 08:36
Show Gist options
  • Select an option

  • Save japharr/c07ae243eca3854ecf01575523243f50 to your computer and use it in GitHub Desktop.

Select an option

Save japharr/c07ae243eca3854ecf01575523243f50 to your computer and use it in GitHub Desktop.
Invoke a method every 5 seconds in Android
private final FIVE_SECONDS = 5000;
public void scheduleSendLocation() {
handler.postDelayed(new Runnable() {
public void run() {
sendLocation(); // this method will contain your almost-finished HTTP calls
handler.postDelayed(this, FIVE_SECONDS);
}
}, FIVE_SECONDS);
}
@AliAzaz

AliAzaz commented Sep 23, 2021

Copy link
Copy Markdown

Any better way to deal with this issue? Because this answer is almost 5Year old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment