Created
February 25, 2017 08:36
-
-
Save japharr/c07ae243eca3854ecf01575523243f50 to your computer and use it in GitHub Desktop.
Invoke a method every 5 seconds in Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any better way to deal with this issue? Because this answer is almost 5Year old.