androidandroid-dialogfragmentdismissorientation-changes

Android : How to dismiss a DialogFragment on orientation change?


I would like dismiss a DialogFragment on orientation change.

The problem is that the OnConfigurationChanged() is never called.

And call :

this.dismiss();

From the onDetach() method, returns a null pointer exception. What can I do?


Solution

  • Overriding :

    public void onPause() {
        super.onPause();
    
        this.dismiss();
    }
    

    instead of OnConfigurationChanged(), did the trick.