public class MyApplication extends Application { private LinkedList<Activity> list =null; private static MyApplication instance; MyApplication(){ list=new LinkedList<Activity>(); } public static MyApplication getInstance(){ if (instance==null){ return instance=new MyApplication(); } return instance; } public void addActivity(Activity activity) { if (list != null && list.size() > 0) { if(!list.contains(activity)){ list.add(activity); } }else{ list.add(activity); } } public void exit() { if (list != null && list.size() > 0) { for (Activity activity : list) { activity.finish(); } } System.exit(0); } }