1

I have a custom Dialog class in which I instantiate the dialog like this

dg = new Dialog(con); 
dg.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = dg.getWindow();
window.setBackgroundDrawableResource(android.R.color.transparent);
dg.setContentView(R.layout.listview_dialog_layout); 

//set views etc..

dg.show();

When an orientation change occurs in the activity that the dialog is shown the activity data changes are lost but the dialog still stays open. I would like the dialog to be dismissed at orientation changes just like it happens with the default Dialog created through an AlertDialog.Builder. How can I do that?

I prefer a solution that is implemented in the custom Dialog class instead of going to every activity and type dialog.dismiss(); at activity pause or stop

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
Anonymous
  • 4,470
  • 3
  • 36
  • 67

1 Answers1

1

See my answer here

This method lets you detect orientation changes for a dialog without a reference to an Activity. It requires a custom view within the dialog, though. If you can pass an instance of your custom dialog class to the custom view, you can call dialog.dismiss(); directly within the onConfigurationChanged() method of the custom view.

Community
  • 1
  • 1
kpninja12
  • 529
  • 6
  • 11