import android.os.Handler; import android.os.Looper; import android.os.Message; public class InvokeLater{ private static Handler handler = new Handler(Looper.getMainLooper()){ @Override public void handleMessage(Message msg) { Runnable task = (Runnable) msg.obj; task.run(); } }; public static void post(Runnable task){ Message msg = Message.obtain(); msg.obj = task; handler.sendMessage(msg); } }