Reputation: 1150
In my Android App I have a main activity and some other activities. The others get started with a button from the main one.
When I enter an activity and for example toggle some toggleViews, return back to main view and then again enter the sub activity, all the changes are lost.
Changing the manifest.xml
to
<activity android:name="MySubActivity"
android:launchMode="singleTask" >
</activity>
does not help.
Also the Methods onSaveInstanceState
and onRestoreInstanceState
do not work because the sub activity gets killed as soon as I leave it. So the data is saved but it can never be loaded because the Bundle of onCreate(Bundle savedInstanceState)
seems to be always null
.
How can I keep the status of all the inputs (better) or prevent the activity from getting killed (worse)?
Upvotes: 1
Views: 422
Reputation: 28162
Save data somewhere persistent, like database, preferences, serialized objects. You are starting a new activity not restarting the old one.
Upvotes: 4