Java tutorial
//package com.java2s; //License from project: Open Source License import android.view.View; public class Main { public static void runOnViewThread(View view, Runnable runnable) { if (view.getHandler() == null || view.getHandler().getLooper() == null || view.getHandler().getLooper().getThread() == Thread.currentThread()) { runnable.run(); } else { view.post(runnable); } } }