Skip to content

Instantly share code, notes, and snippets.

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 progmonster/4b698bf2e6ebedb7380f to your computer and use it in GitHub Desktop.
Save progmonster/4b698bf2e6ebedb7380f to your computer and use it in GitHub Desktop.
Android (at least API level 11). Update UI from not UI thread via Activity.runOnUiThread method.
//----- inside an Activity class ----------
// ... Create task in separate thread:
Runnable heavyTask = new Runnable() {
@Override
public void run() {
// do heavy work...
runOnUiThread(new Runnable() {
@Override
public void run() {
// Update UI...
}
});
}
}
new Thread(heavyTask).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment