is Main Thread - Android java.lang

Android examples for java.lang:Thread

Description

is Main Thread

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Looper;

public class Main {
    @TargetApi(Build.VERSION_CODES.CUPCAKE)
    public static boolean isMainThread() {
        return Looper.getMainLooper().getThread() == Thread.currentThread();
    }//from  w w w.  j a  va2 s  .co m
}

Related Tutorials