سؤال

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.

هل كانت مفيدة؟

المحلول

You can use adb for this:

adb shell dumpsys activity

نصائح أخرى

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>

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}

If just want to look Activity backstack use below set commands

adb shell

dumpsys activity | grep -i run

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top