1. 程式人生 > >ANDROID----如何隨時隨地退出活動

ANDROID----如何隨時隨地退出活動

首先建立一個類:
public class CollectorActivity{
public static List activities=new ArrayList<> ();
public static void addActivity(Activity activity){
activities.add(activity);
}
public static void removeActivity(Activity activity){
activities.remove(activity);
}
public static void clearAll(){
for(Activity activity:activities){
if(!activity.isFinishing()){
activity.finish();
}
}
activites.clear();
}
}