Activity restart on rotation change

Viewed 140

I have an activity. That activity contains a Fragment within a ViewPager. The fragment needs to copy files (with a ProgressDialog), but when I rotate the screen when it is busy, the activity restarts and everything just stops.

I tried adding android:configChanges="orientation|screenSize" to the AndroidManifest but that wont be a solution either because then my AdView and Toolbar won't reload on a rotation change:

Before:

After:

(Notice the difference with the Toolbar and AdView height?)

How can I keep the Activity/Fragment alive, with a working Toolbar and AdView?

Thanks

1 Answers
Related