Created
February 22, 2018 11:12
-
-
Save odai-alali/916d643a13525e1e9a3b2b4516ad1236 to your computer and use it in GitHub Desktop.
The equivalent to a JavaScript setInterval/setTimeout in Android/Java?
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
// setInterval() | |
new Timer().scheduleAtFixedRate(new TimerTask(){ | |
@Override | |
public void run(){ | |
Log.i("interval", "This function is called every 5 seconds."); | |
} | |
},0,5000); | |
// setTimeout() | |
new android.os.Handler().postDelayed( | |
new Runnable() { | |
public void run() { | |
Log.i("timeout","This function is called after 5 seconds."); | |
} | |
}, 5000); |
Just in time I was searching for this
Happy to help 🙂
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just in time I was searching for this