Hi,
My app is made of two activities, A and B. I'm considering this sequence of steps:
- Activity A is started.
- A launches B [A is paused, B is running].
- B launches a map intent [A and B are both paused now].
Now the user is using the maps application and the system decides it needs more memory. Can the system kill only one of my activities for memory, or will it always kill all activities in a "process" in this situation?
Both activities share some static data like:
class Data {
public static String mName;
public void save() {
// write to file: mName;
}
public void load() {
// mName = read from file;
}
}
ActivityA.mTextView.setText(Data.mName);
ActivityB.mListView.addText(Data.mName);
so when any activity in my app gets onSaveInstanceBundleSate() called, I call Data.save() to write it to disk. Now the question is, in an Activity's onCreate() method, should I simply check to see if Data.mName == null, and if so, assume the Activity is returning from a kill state, and try restoring from disk again? I'm unclear when this restoring should be done, considering Activity A may or may not still be alive etc. - and I don't want to corrupt state if Activity A is still alive but B is coming back from a kill state,
Thanks
Thanks