@@ -0,0 +1,890 @@
+package com.example.ddmeng.helloactivityandfragment.utils;%0A%0Aimport android.app.ActivityManager;%0Aimport android.content.ComponentName;%0Aimport android.content.Context;%0Aimport android.util.Log;%0A%0Aimport java.util.List;%0A%0Apublic class TaskUtils %7B%0A%0A    private static final String LOG_TAG = %22Stack%22;%0A%0A    public static String getCurrentTopActivityName(Context context) %7B%0A%0A        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);%0A%0A        //this method requires android.permission.GET_TASKS%0A        List%3CActivityManager.RunningTaskInfo%3E runningTasks = activityManager.getRunningTasks(2);%0A        //this method was deprecated in API level 21%0A        ComponentName topActivity = runningTasks.get(0).topActivity;%0A        Log.i(LOG_TAG, %22top Activity: %22 + topActivity.getShortClassName());%0A        return topActivity.getShortClassName();%0A%0A    %7D%0A%7D%0A

add TaskUtils class to get activity back stack information