Skip to content Skip to sidebar Skip to footer

Android Custom Dialog Gives An Error

In my android app I have to popup a dialog on a button click event. But when I click on the button the app stops working. I load the pre designed layout into the dialog. I will pos

Solution 1:

change

finalDialogdialog=newDialog(getApplication());

to

finalDialogdialog=newDialog(YourActivity.this);

and if you are inside Fragment, change to

finalDialogdialog=newDialog(getActivity());

Dialog requires a Context reference whose window token is not null. here ApplicationContext's window token is null where as Activity will have it's own window

Post a Comment for "Android Custom Dialog Gives An Error"