I\'m trying to open a dialog window, but every time I try to open it it throws this exception:
Uncaught handler: thread main exiting due to uncaught exceptio
Try to reset dialog
window's type to
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT:
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
Don't forget to use the permission android.permission.SYSTEM_ALERT_WINDOW
You cannot display an application window/dialog through a Context that is not an Activity. Try passing a valid activity reference
Don't use getApplicationContext()
on declaring dialouge
Always use this
or your activity.this
Instead of :
Context appContext = this.getApplicationContext();
you should use a pointer to the activity you're in (probably this
).
I got bitten by this today too, the annoying part is the getApplicationContext()
is verbatim from developer.android.com :(
Just change it into
AlertDialog.Builder alert_Categoryitem =
new AlertDialog.Builder(YourActivity.this);
Instead of
AlertDialog.Builder alert_Categoryitem =
new AlertDialog.Builder(getApplicationContext());
Ditto on the getApplicationContext thing.
The documents on the android site says to use it, but it doesn't work...grrrrr :-P
Just do:
dialog = new Dialog(this);
"this" is usually your Activity from which you start the dialog.