User
User

Reputation: 722

How to get dialog that is attached with DialogFragment? [ANDROID]

In my app i am using DialogFragment to show a dialog for some seconds, now when i change my device's screen orientation, app crashes because the context i am using in my Dialog fragment goes null. After searching i found that in my activity's onDestroy() method i should dismiss that dialog if it is already showing so that my app doesn't crash. Now i need to get that dialog that is showing how i can get it? so that i can implement a check on it Any suggestions will be appreciated

Upvotes: 1

Views: 399

Answers (1)

Arun kumar
Arun kumar

Reputation: 1894

add in your menifest file

"android:configChanges="orientation|screenSize"

in the actvity tag like below :

<activity
            android:name=".activities.HistoryDefectDetail"
            android:configChanges="orientation|screenSize" />

Upvotes: 2

Related Questions