0

I have created one instance of DialogFragment. It is getting created properly. But when I lock screen, it is getting detach and dismiss. Thus when I unlock screen, I can't see my dialogfragment which I saw just 2 secs ago before lock screen. I want to prevent dismissing of dialogfragment on locking the screen. Please help me.

Thanking in advance.

  • Are you displaying your DialogFragment in an Activity or a Fragment? – Nicklas Jensen Sep 10 '14 at 17:42
  • I have one activity X as below public class X extends Activity { DialogFragment dialog = Y.newDialog(Z, new OnCancelListener() { @Override public void cancel() { finish(); } }); try { dialog.show(getFragmentManager(), "dialog"); } catch(IllegalStateException e){ Log.e(TAG,"IllegalStateException when dialog show"); } } Another activity Y is as below public class Y extends DialogFragment { Here I am creating my dialog with help of method "newDialog(a,b)" . } – user3021625 Sep 11 '14 at 05:30
  • Please edit your question with the code that's giving you troubles – Nicklas Jensen Sep 11 '14 at 10:32

1 Answers1

1

I think in any case the simplest way should be to remove the dialog in onPause() yourself and and show it again in onResume(). In that way the dialog will also change according to the config changes [Like language change].

singularity
  • 147
  • 1
  • 11