Last active
July 4, 2016 04:57
-
-
Save Pulimet/6cf1d0e1ab5f59e6711c to your computer and use it in GitHub Desktop.
UI / non UI thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Looper.getMainLooper().equals(Looper.myLooper())) { | |
// UI thread | |
} else { | |
// Non UI thread | |
} | |
// Run on UI | |
new Handler(Looper.getMainLooper()).post(new Runnable() { | |
@Override | |
public void run() { | |
Log.d("UI thread", "I am the UI thread"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment