There is no problem reaching the user interface thread from backGround thread (more clearly: from the doInBackground () method): you just need to run the runOnUiThread() method in your context. In my case, I call it from the body of doInBackground() .
ContactsViewerActivity.this.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(ContactsViewerActivity.this); builder.setTitle("Connection problem..") .setMessage("Could not connect to " + url + ", " + "try changing your host in the settings to default one :" + getResources().getString(R.string.default_server_ip) + ":" + getResources().getString(R.string.default_server_port)) .setNegativeButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } });
source share