Created
May 20, 2014 11:13
-
-
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.
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
//----- 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