Skip to content

Instantly share code, notes, and snippets.

@badgercl
Last active December 30, 2015 12:29
Show Gist options
  • Select an option

  • Save badgercl/7829547 to your computer and use it in GitHub Desktop.

Select an option

Save badgercl/7829547 to your computer and use it in GitHub Desktop.
Runs code on the Android Application's main thread when no Activity is present (usually when using services)
final Context context_t = cntxt;
Handler mainHandler = new Handler(cntxt.getMainLooper());
Runnable locRunnable = new Runnable() {
@Override
public void run() {
// Code
}
};
mainHandler.post(locRunnable);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment