Is there a way to see the activity stack while the code is in startup?
You can use ActivityManager.RunningTaskInfo . Although it does not provide many APIs, it is probably sufficient for your requirements. Pseudocode:
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(10); ActivityManager.RunningTaskInfo firstTask = runningTasks.get(0); String topActivityName = firstTask.topActivity.getShortClassName(); String rootActivityName = firstTask.baseActivity.getShortClassName();
It gives you the ability to extract the top and root operations of a specific task (AKA. Back stack). Please note: you need to set persimmon GET_TASKS to AndroidManifest.xml.
source share