Skip to content

Instantly share code, notes, and snippets.

@Pulimet
Last active July 4, 2016 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pulimet/6cf1d0e1ab5f59e6711c to your computer and use it in GitHub Desktop.
Save Pulimet/6cf1d0e1ab5f59e6711c to your computer and use it in GitHub Desktop.
UI / non UI thread
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