How to check if running on UI thread in Android? [duplicate]

Use Looper.getMainLooper().getThread() to get the UI thread. You can check if it is the current thread using the following expression:

Looper.getMainLooper().getThread() == Thread.currentThread()

Leave a Comment