print the current back stack in the log

丶灬走出姿态 提交于 2019-12-03 09:14:49

问题


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 activity is popped off the stack after its onDestroy() is called.


回答1:


You can use adb for this:

adb shell dumpsys activity



回答2:


To improve on Paul's answer and see data relevant to your app only you can do:

adb shell dumpsys activity package <your.package.name>



回答3:


Use the command below can show tasks and activity backstack

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

And result looks like this:

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}



回答4:


If just want to look Activity backstack use below set commands

adb shell

dumpsys activity | grep -i run



来源:https://stackoverflow.com/questions/11549366/print-the-current-back-stack-in-the-log

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!