package com.close;
import java.util.LinkedList;
import java.util.Stack;
import android.app.Activity;
public class ActivityManager {
private static LinkedList<Activity> acys;
private static ActivityManager instance = null;
private ActivityManager (){}
public static ActivityManager getInstance(){
if(instance == null){
instance = new ActivityManager ();
acys = new LinkedList<Activity>();
}
return instance;
}
public void add(Activity acy)
{
acys.add(acy);
}
public void remove(Activity acy)
{
acys.remove(acy);
}
public void closeAll()
{
Activity acy;
while(acys.size() != 0)
{
acy = acys.poll();
if(!acy.isFinishing())
acy.finish();
}
}
}
1.第一种方法:自己定义一个管理Activity的栈