android - Why onDestroy recreates the Fragments when Activity recreate after process killed -
i'm trying understand happens fragments
when activity
recreates after process gets killed , activity destroy
.
scenario : have application multiple activities , first activity loads configuration , used other activities. on low memory when application on background ,the process gets killed . after process killed if select application (from recent apps) , activity recreating. current activity when recreates try access configuration , app crashes.
so , decided finish activity if configuration not loaded on activity recreate , , navigate first activity loads configuration. resolves of problems , if activity has fragment , when ondestroy
happens on recreate , app crashes ondestroy
trying recreate fragments.
at android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:973) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1138) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1120) @ android.support.v4.app.fragmentmanagerimpl.dispatchreallystop(fragmentmanager.java:1956) @ android.support.v4.app.fragmentactivity.onreallystop(fragmentactivity.java:790) @ android.support.v4.app.fragmentactivity.doreallystop(fragmentactivity.java:767) @ android.support.v4.app.fragmentactivity.ondestroy(fragmentactivity.java:314)
i tried remove fragments in ondestory
doesn't work.
you try save configuration in onpause() method, , reload when activity recreate.
Comments
Post a Comment