2012-01-09 11 views
5

Mi código está a continuación y funciona perfectamente bien cuando se llama desde onCreate() No tengo ni error ni stracktrace. Simplemente no se muestra.¿Por qué mi AlertDialog no se mostrará cuando se cree en onResume() o onActivityResult()?

AlertDialog.Builder builder = new AlertDialog.Builder(this); 
builder.setMessage("Are you sure you want to exit?") 
    .setCancelable(false) 
    .setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int id) { 
      finish(); 
     } 
    }) 
    .setNegativeButton("No", new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int id) { 
      dialog.cancel(); 
     } 
    }); 
AlertDialog alert = builder.create(); 
alert.show(); 

Respuesta

2

Trate ..

AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this); 
    dlgAlert.setMessage("This is an alert with no consequence"); 
    dlgAlert.setTitle("App Title"); 
    dlgAlert.setPositiveButton("OK", null); 
    dlgAlert.setCancelable(true); 
    dlgAlert.create().show(); 

llamada .show() el constructor en el código.

+0

Gracias, funciona desde onResume pero aún no desde onActivityResult(). ¿Alguna idea? – znat

+0

¿Cómo se ve tu código onActivityResult()? –

Cuestiones relacionadas