How To Save Lot Of Object In Onretainnonconfigurationinstance() In Android
Solution 1:
How to save lot of object in onRetainNonConfigurationInstance() in android like textview with value and webview with value .
Your example is invalid. Never pass widgets between activity instances yourself, as you will create memory leaks.
For stuff like WebView
, use fragments, and call setRetainInstance(true)
on the WebView
-hosting fragment. Android will then handle all of the details to keep that WebView
in its fragment alive and attach it to the activity created after a configuration change.
For cases where you have more than one object to return from onRetainNonConfigurationInstance()
, and they will not introduce memory leaks, use a static inner class, or a java.util
collection class, or something as the container for all those objects, and return the container from onRetainNonConfigurationInstance()
.
Post a Comment for "How To Save Lot Of Object In Onretainnonconfigurationinstance() In Android"