Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import android.os.Looper; public class Main { /** * @return true iff the current thread is the main (UI) thread. */ public static boolean runningOnUiThread() { return Looper.getMainLooper() == Looper.myLooper(); } }