(Android) Delay method call


This is how you could delay a method call for a given amount of time. I’ve used this to have an alert dialog pop up a few second after starting an activity.

This will fire myMethod() after 3000 miliseconds:
[java]
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
myMethod();
}}, 3000);
[/java]

Leave a Reply

Your email address will not be published. Required fields are marked *