In my Andriod app, I've got a Dialog extended from AppCompatDialogFragment. I show it immediatelly in my App's main Activity's onCreate:
@Override
protected void onCreate(Bundle savedState)
{
super.onCreate(savedState);
// ....
if( savedState==null )
{
MyDialog diag = new MyDialog();
diag.show(getSupportFragmentManager(), null);
}
}
later on I want to dismiss this dialog - so I need to find it. I cannot simply remember a reference to it in my Activity, as when I e.g. rotate the phone the Dialog gets recreated and my reference would be invalid.
How do I get a reference to MyDialog later on in my code?