I just saw a piece of code:
public class MyApplication extends Application {
private List<Activity> activityList = new LinkedList<Activity>();
private static MyApplication instance;
private MyApplication() {
}
public static MyApplication getInstance() {
if (null == instance) {
instance = new MyApplication();
}
return instance;
}
public void addActivity(Activity activity) {
activityList.add(activity);
}
public void exit() {
for (Activity activity : activityList) {
activity.finish();
}
System.exit(0);
}
}
I never thought that we can take control of other activity beside the current one. I usually call finish() inside its own activity, now I saw this code, I realize that we can finish() other activity as well.
Android stack is back stack architecture, so if I destroy any activity in the middle, what will happen? For example, I have 5 activity in the back stack, let say I finish() the third one, will the second and fourth be linked together now?