(Android) Delay method call

By | November 1, 2014

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:

				Handler handler = new Handler();
				handler.postDelayed(new Runnable() {
					@Override
					public void run() {
						myMethod();			
					}}, 3000);

Leave a Reply

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