Home > DeveloperSection > Forums > How to force recreation of Activity/Fragment on restore
Anurag Sharma
Anurag Sharma

Total Post:40

Points:280
Posted on    January-23-2015 10:01 PM

 Mobile Development Android  Android Activity 
Ratings:


 1 Reply(s)
 641  View(s)
Rate this:

I am having a number of issues around saving app state to a Bundle via onSaveInstanceState().

For now, I need to address the issue of my app crashing when it restored after being closed by Android.

When an Activity/Fragment (in background) is being force closed by Android to regain resources, is there a way I can say "don't try and restore state when resume, just create everything anew"?

Thanks



Monaj Singh
Monaj Singh

Total Post:41

Points:287
Posted on    January-23-2015 10:28 PM

For activity if you want to create it from scratch then just override onSaveInstanceState and call super.onSaveinstanceState passing a null al the Bundle.

For Fragment just set setRetainInstanceState to false in onActivityCreated method of the Fragment.


Modified On Apr-04-2016 07:43:37 AM

Don't want to miss updates? Please click the below button!

Follow MindStick