Want to call a method after a delay in Android? Use the below example code using Java and Kotlin.
Kotlin example:
1 2 3 | Handler().postDelayed({ //Do something after 100ms }, 100) |
Java example:
1 2 3 4 5 6 7 | final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 100ms } }, 100); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.