随时随地退出程序
需要一个专门的集合类对对所有的活动进行管理就行了
package com.example.deligence.activitytest; import android.app.Activity; import java.util.ArrayList; import java.util.List; /** * Created by Deligence on 2017/4/16. */ public class ActivityCollector { public static List<Activity> activities = new ArrayList<Activity>(); public static void addActivity(Activity activity){ activities.add(activity); } public static void removeActivity(Activity activity){ activities.remove(activity); } public static void finishAll(){ for (Activity activity:activities) { if(!activity.isFinishing()){ activity.finish(); } } } }
killProgress方法 用于杀掉一个进程
//杀掉当前程序代码 android.os.Process.killProcess(android.os.Process.myPid());