Hey,
I’m going to show you how to delay a method or a code segment on Android with a piece of code particle. It’s very easy and useable as you need.
I’m going to show you how to delay a method or a code segment on Android with a piece of code particle. It’s very easy and useable as you need.
new Handler().postDelayed(new Runnable() { @Override public void run() { // Magic here } }, 1000); // Millisecond 1000 = 1 secFirst you need to create a Handler object and use its own method which is “postDelayed” and override the Runnable object’s run method. If you need a specific time to delay like 1000 millisecond (1 second), this method is great to use.Important Note : After using this postdelayed method, never forget to stop runnable and more importantly, NEVER use it for UI Staff. Otherwise, your UI or your whole app may crash. Thank you Wayne May for this note.