I have a list containing Activity-A, each Activity-A has different values inside it. However they all have the same class, which is Activity-A. When the user navigates back to the list from an activity, I store that activity in an ArrayList and retrieve it and start it as an intent when the user clicks on the same activity in the list again. However, that causes it to be re-created. I want it to be resumed from the state it was stored in the ArrayList. How can I do this?
Edit: I've heard of the FragmentManager and how it easily stores and can retrieve fragments. However, is there something like FragmentManager for activities? Is ActivityManager like the FragmentManager?
Edit: To clarify my question a bit more, I'm trying to:
- Save the FragmentActivity to an ArrayList when it gets stopped
- Resume it from the state before it was stopped.
However, when I navigate to the FragmentActivity stored in the ArrayList, the FragmentActivity is recreated from scratch, instead of resuming from its previous state.
I understand that I have to do something with saving its state. However, I doubt I can save all of its inside contents; there's lots of fragments in it.
Here's the code:
listItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showActivity(id);
}
private void showActivity(int id) {
ActivityA activityA = StaticLab.get(getActivity())
.getActivityA(id); // getActivityA simply returns the ActivityA from the ArrayList which contains the specified id
if (activityA == null) {
createNewActivityA()
}
Intent i = new Intent(getActivity(), activityA.getClass());
startActivity(i);
}