You must update your user interface in the user interface thread.
To do this, create a handler in the onCreate () method:
private Handler mHandler; @Override public void onCreate() { mHandler = new Handler();
Then call the handler in a separate thread to execute it in the main thread:
mHandler.post(new Runnable() { @Override public void run() {
source share