Print current back stack in log

Is there a way to print the current back stack of the current task in an Android app? In particular, I want to understand when an action is called from the stack after onDestroy () is called.

+8
android user-interface back-stack
source share
4 answers

You can use adb for this:

adb shell dumpsys activity 
+4
source share

To improve Paul’s answer and see the data related to your application, you can only do:

 adb shell dumpsys activity package <your.package.name> 
+16
source share

Use the command below to show tasks and backstack activity

 adb shell dumpsys activity activities | sed -En -e '/Running activities/,/Run #0/p' 

And the result is as follows:

 Running activities (most recent first): TaskRecord{29b17859 #1134 A=com.google.android.dialer U=0 sz=1} Run #0: ActivityRecord{180fd6be u0 com.google.android.dialer/.extensions.GoogleDialtactsActivity t1134} Running activities (most recent first): TaskRecord{7764a61 #1054 A=com.google.android.googlequicksearchbox U=0 sz=1} Run #1: ActivityRecord{2900994b u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL t1054} TaskRecord{4aa804c #1129 A=com.android.systemui U=0 sz=1} Run #0: ActivityRecord{1816140b u0 com.android.systemui/.recents.RecentsActivity t1129} 
+3
source share

If you just want to see how Backstack Activity works, use the set commands

adb shell

Activity dumpsys | grep -i run

+2
source share

All Articles