Back
I need to check if the thread running a certain piece of code is the main (UI) thread or not. How can I achieve this?
Try:
Looper.myLooper() == Looper.getMainLooper()
if this generates true, then you're on the UI thread!
31k questions
32.8k answers
501 comments
693 users