public class MyApplication extends Application {
private List
activityList = new LinkedList();
private static MyApplication instance;
private MyApplication()
{
}
//单例模式中获取唯一的MyApplication实例
public static MyApplication getInstance()
{
if(null == instance)
{
instance = new MyApplication();
}
return instance;
}
//添加Activity到容器中
public void addActivity(Activity activity)
{
activityList.add(activity);
}
//遍历所有Activity并finish
public void exit()
{
for(Activity activity:activityList)
{
activity.finish();
}
System.exit(0);
}
}