// Path: utilslibrary/src/main/java/com/devin/UtilManager.java
// public class UtilManager {
// 
//     private static Context mContext;
// 
//     /**
//      * 初始化工具类集合
//      * @param context  context
//      */
//     public static void init(Context context) {
//         mContext = context.getApplicationContext();
//     }
// 
//     public static Context getContext() {
//         return mContext;
//     }
// }


import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import com.devin.UtilManager;
import java.util.Stack;

    /**
     * 结束堆栈中最后一个压入Activity
     */
    public void finishLastActivity() {
        Activity activity = activityStack.lastElement();
        finishActivity(activity);
    }


    /**
     * 结束指定类名的Activity
     *
     * @param cls
     */
    public void finishActivity(Class<? extends Activity> cls) {
        for (Activity activity : activityStack) {
            if (activity.getClass().equals(cls)) {
                finishActivity(activity);
            }
        }
    }


    /**
     * 退出应用程序
     */
    public void exitApp() {
        try {
            finishAllActivity();
// Path: utilslibrary/src/main/java/com/devin/UtilManager.java
// public class UtilManager {
// 
//     private static Context mContext;
// 
//     /**
//      * 初始化工具类集合
//      * @param context  context
//      */
//     public static void init(Context context) {
//         mContext = context.getApplicationContext();
//     }
// 
//     public static Context getContext() {
//         return mContext;
//     }
// }


// Path: utilslibrary/src/main/java/com/devin/util/AppActivityManager.java
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import com.devin.UtilManager;
import java.util.Stack;


    /**
     * 结束堆栈中最后一个压入Activity
     */
    public void finishLastActivity() {
        Activity activity = activityStack.lastElement();
        finishActivity(activity);
    }


    /**
     * 结束指定类名的Activity
     *
     * @param cls
     */
    public void finishActivity(Class<? extends Activity> cls) {
        for (Activity activity : activityStack) {
            if (activity.getClass().equals(cls)) {
                finishActivity(activity);
            }
        }
    }


    /**
     * 退出应用程序
     */
    public void exitApp() {
        try {
            finishAllActivity();
            ActivityManager activityMgr = (ActivityManager) UtilManager.getContext().getSystemService(Context.ACTIVITY_SERVICE);