0

I'm showing a dialog fragment like progressDialog.show(getSupportFragmentManager());

When my thread finishes, the dialog is dismissed. This is not working after screen rotation, because my 'progressDialog' variable is not set.

Using progressDialog.show(getSupportFragmentManager(), "progressDialog"); and retaining the fragment manually would work, but this function is deprecated...

So what is the correct way to do this?

Ranco
  • 893
  • 2
  • 13
  • 43
prom85
  • 16,896
  • 17
  • 122
  • 242

1 Answers1

0

You have to save instance state of your fragment or activity. After rotating your device you can obtain Bundle in fragment or activity.

In this bundle you can store whatever you want from primitive types throug string arrays to Serializable and Parcelable object, so you can configure saved state as you wish.

If your progressDialog requires only visible state you can just store some flag like isProgressBarShownig in your instance state bundle.

Kamil Lelonek
  • 14,592
  • 14
  • 66
  • 90
  • that's what I usually do... Now I read, that `FragmentDialogs` are managed by their parent activities and they are at least displayed again after screen rotation... Now I can't dismiss this dialog anymore... only with the back button... – prom85 Jul 30 '13 at 07:04
  • So maybe try http://developer.android.com/reference/android/app/Activity.html#onBackPressed() to dismiss dialog. – Kamil Lelonek Jul 30 '13 at 08:02
  • thanks for the halp, but I found the solution already... actually, the function meantioned in my question is NOT depraced... I'm using a library in which the wrapper was depraced... Not the function itself... – prom85 Jul 30 '13 at 11:51