Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save codeswimmer/832786 to your computer and use it in GitHub Desktop.

Select an option

Save codeswimmer/832786 to your computer and use it in GitHub Desktop.
Android: determine if you're running on the main UI thread
package com.codeswimmer.android.util;
import android.os.Looper;
public class ThreadUtil {
public static final boolean isRunningOnUiThread() {
return Looper.getMainLooper().getThread() == Thread.currentThread();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment