I have 3 activities A, B and C.
I inflate activity B dynamically on a button click and the user can add as many views as he likes.
The operation is like this:
User sees “Activity A” first enters his details and clicks the save button and I take him to “Activity B” where he adds certain fields as many times he likes and when he clicks save again I take him to “Activity C”.
Now when I am at A and go to B and add some views and enter text in TextViews and then hit save and go to C. From C if I hit back I see B intact along with all the inflated views and entered text obviously because it is saved in the Back Stack, but if I go from B to A by hitting back and then come back to B all the views are gone because it is removed from the Back Stack.
I wanted to know if it is possible to hold only one instance of B in the BackStack and not kill it at all when the user hits back?
I had overriden back key but to no avail because the activity is killed anyways, some people suggested that I should save the entire views and data from it to a Parcelable ArrayList and regenerate them again in onCreate but that doesnt look feasible to me as I think we can save it in BackStack anyway.
I came across this guide at android developers http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html which says about these activity attributes
android:taskAffinity
android:launchMode
android:allowTaskReparenting
android:clearTaskOnLaunch
android:alwaysRetainTaskState
android:finishOnTaskLaunch
android:singleTask
android:singleInstance
But I am unaware of how to put them to use.
Has anyone tried this out yet? If so please help me put the pieces together.
Yes,I agree with Nandeesh.
Thank you I think this little bit information will be helpful for u.