Example usage for android.os Looper getMainLooper

List of usage examples for android.os Looper getMainLooper

Introduction

In this page you can find the example usage for android.os Looper getMainLooper.

Prototype

public static Looper getMainLooper() 

Source Link

Document

Returns the application's main looper, which lives in the main thread of the application.

Usage

From source file:Main.java

private static boolean isMain() {
    return Looper.getMainLooper().getThread() == Thread.currentThread();
}

From source file:Main.java

public static void ensureUiThread() {
    if (Looper.getMainLooper() != Looper.myLooper()) {
        throw new RuntimeException("Invalid access, not in UI thread");
    }/*from w  ww  . j a  v a 2  s . co m*/
}

From source file:Main.java

public static boolean isUIThread() {
    return Looper.getMainLooper().getThread() == Thread.currentThread();
}

From source file:Main.java

public static boolean isMainThread() {
    return Looper.getMainLooper() == Looper.myLooper();
}

From source file:Main.java

public static final boolean isOnUiThread() {
    return Looper.getMainLooper().getThread() == Thread.currentThread();
}

From source file:Main.java

public static boolean isMainLooperThread() {
    return Looper.getMainLooper().getThread() != Thread.currentThread();
}

From source file:Main.java

public static boolean isUIThread() {
    long uiId = Looper.getMainLooper().getThread().getId();
    long cId = Thread.currentThread().getId();
    return uiId == cId;
}

From source file:Main.java

public static void checkBackgroudThread() {

    if (Looper.getMainLooper() == Looper.myLooper()) {
        throw new IllegalStateException("It must run in backgroud thread.");
    }//  w ww  .j  a  v  a  2s  . c  o m
}

From source file:Main.java

private static final boolean currentThreadIsUiThread() {
    return Looper.getMainLooper().getThread() == Thread.currentThread();
}

From source file:Main.java

public static boolean isInMainThread() {
    return Looper.myLooper() == Looper.getMainLooper();
}