有没有办法在Android应用中打印当前任务的当前后退堆栈?特别是,我想了解在调用onDestroy()之后从堆栈中弹出一个活动。
答案 0 :(得分:22)
要改进保罗的答案并查看与您的应用相关的数据,您只能执行以下操作:
adb shell dumpsys activity package <your.package.name>
答案 1 :(得分:6)
使用以下命令可以显示任务和活动backstack
adb shell dumpsys activity activities | sed -En -e '/Running activities/,/Run #0/p'
结果如下:
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}
答案 2 :(得分:5)
您可以使用adb:
adb shell dumpsys activity
答案 3 :(得分:2)
如果只想查看Activity backstack,请使用以下set命令
adb shell
dumpsys活动| grep -i run