Monday, April 15, 2013

[android-developers] Re: exception when create new AlertDialog

Thanks, works perfectly

Very thanks I spent hours working on this problem

El domingo, 14 de abril de 2013 20:50:18 UTC+2, Jonathan S escribió:
on new AlertDialog.Builder(getApplication());, replaces getApplication() to MainActivity.this


On Sunday, April 14, 2013 10:55:42 AM UTC-4, Carlos Calvo wrote:
Hello,

I have a ProgressDialog running. Execute method ".dismiss" for destroy them.

But when i create a new AlertDialog i take a exception because the progessdialog yet still show

Exception "Unable to add window -- token null is not for an application"

The code:

                               if (pd.isShowing()){
pd.dismiss();
}
MainActivity.this.runOnUiThread(new Runnable() {

       public void run() {
                
        AlertDialog.Builder builder = new AlertDialog.Builder(getApplication());
builder.setTitle("Lo sentimos por el Fallo")
.setMessage("Resolveremos el fallo lo antes posible")
.setCancelable(false)
.setIcon(R.drawable.ic_exception)
.setPositiveButton("Enviar Fallo",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//enviar por mail traza exception
mDamageReport.submit( new Exception() );
finish();
}
})
.setNegativeButton("Cerrar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
finish();
}
});

builder.create().show();

       }
   });

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment