No entiendo por qué recibo este error. Estoy usando AsyncTask para ejecutar algunos procesos en segundo plano.
Yo tengo:
protected void onPreExecute()
{
connectionProgressDialog = new ProgressDialog(SetPreference.this);
connectionProgressDialog.setCancelable(true);
connectionProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
connectionProgressDialog.setMessage("Connecting to site...");
connectionProgressDialog.show();
downloadSpinnerProgressDialog = new ProgressDialog(SetPreference.this);
downloadSpinnerProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
downloadSpinnerProgressDialog.setMessage("Downloading wallpaper...");
}
Cuando entro doInBackground()dependiendo de una condición, yo:
[...]
connectionProgressDialog.dismiss();
downloadSpinnerProgressDialog.show();
[...]
Siempre que lo intento downloadSpinnerProgressDialog.show(), recibo el error.
¿Alguna idea chicos?

Tuve un problema similar, pero al leer esta pregunta pensé que podría ejecutar el hilo de la interfaz de usuario:
YourActivity.this.runOnUiThread(new Runnable() { public void run() { alertDialog.show(); } });Parece que me sirve.
fuente
También me costó mucho hacer que esto funcionara, la solución para mí fue usar las respuestas hyui y konstantin,
class ExampleTask extends AsyncTask<String, String, String> { // Your onPreExecute method. @Override protected String doInBackground(String... params) { // Your code. if (condition_is_true) { this.publishProgress("Show the dialog"); } return "Result"; } @Override protected void onProgressUpdate(String... values) { super.onProgressUpdate(values); YourActivity.this.runOnUiThread(new Runnable() { public void run() { alertDialog.show(); } }); } }fuente
onProgressUpdate()se ejecutarían automáticamente en el hilo de la interfaz de usuariofinal Handler handler = new Handler() { @Override public void handleMessage(final Message msgs) { //write your code hear which give error } } new Thread(new Runnable() { @Override public void run() { handler.sendEmptyMessage(1); //this will call handleMessage function and hendal all error } }).start();fuente