Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.os.Handler; public class Main { /** * <p>Executes a given runnable on the main thread.</p> * * @param context An activity context. * @param runnable A runnable to execute on the main thread. */ static void runOnMainThread(Context context, Runnable runnable) { Handler handler = new Handler(context.getMainLooper()); handler.post(runnable); } }