Java's equivalent of [self performSelector:foo afterDelay:2]

android, java

Solution

For delayed actions in Android I'd recommend using the Android `Handler` class with its `postDelayed()` method.

Create a handler for your `Activity` as a member variable:

private Handler mHandler = new Handler(); 

And then add your delay action as follows:

mHandler.postDelayed(new Runnable() { 
        public void run() { 
            //Do you thing here
        } 
    },2000);

Problem

i am developing an android app i need to go from one activity to another in that first i need to change the colors of button then a delay (so that the) and then call this same function(the one i am in rite now) in objective-c it is done with [self performSelector:foo afterDelay:2] so i need to the its java equivalent.

Original source