Reputation: 239
I know how to handle "Don't keep activities" option in App. I can use onSaveInstanceState
and onRestoreInstanceState
, etc.
In this question, I want to know how the Android Framework handles the option. eg.
ActivityStack
destroyed?When you switch the app from background to foreground, will the ActivityStack
be recreated? Can you provide some source code.Thank you for your reading. Maybe you can write something. ^_^
Upvotes: 2
Views: 73
Reputation: 95646
I don't have the source code handy, so can't be sure, but I assume that it works as if you would set android:noHistory="true"
on all activities.
The answer to your second question is that the single Activity
would be destroyed, leaving the ActivityStack
empty. When the user returns to the app, a new instance of the Activity
would be created and initialized with the previously saved state of the Activity
. The OS process may or may not be destroyed and recreated in this case, it depends how long the app was left in the background and how aggressive the implementation of the Android framework is (this behaviour is different, depending on device manufacturer and on the amount of resources the device has).
Upvotes: 1