List of usage examples for android.os Looper getThread
public @NonNull Thread getThread()
From source file:Main.java
public static Handler runInUIThread(final Runnable runnable, boolean runImmediatelyIfPossible) { if (runnable == null) { return null; }//from w w w . j a v a 2 s.c o m final Handler handler; Looper mainLooper = Looper.getMainLooper(); if (runImmediatelyIfPossible && (Thread.currentThread() == mainLooper.getThread())) { handler = null; runnable.run(); } else { handler = new Handler(mainLooper); handler.post(runnable); } return handler; }