有没有办法打印Android应用中当前任务的当前回栈?特别是,我想了解Activity在其onDestroy()被调用后何时从栈中弹出。
fcy6dtqo1#
要改进Paul的回答并查看与您的应用相关的数据,只有您可以:
adb shell dumpsys activity package <your.package.name>
jvlzgdj92#
使用下面的命令可以显示任务和活动的堆栈
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}
wlzqhblo3#
如果只想查看活动堆栈,请使用以下设置命令adb shell垃圾场活动|grep-i运行
piztneat4#
您可以使用adb来实现此目的:
adb shell dumpsys activity
8dtrkrch5#
sham的回答很棒
但如果你想进一步缩小范围,我相信以下两节是最相关的:
ACTIVITY MANAGER RECENT TASKS (dumpsys activity recents) mRecentsUid=10130 mRecentsComponent=ComponentInfo{com.google.android.apps.nexuslauncher/com.android.quickstep.RecentsActivity} mFreezeTaskListReordering=false mFreezeTaskListReorderingPendingTimeout=false Recent tasks: * Recent #0: Task{41d503 #1068 type=standard A=10287:app.ericn.myapp U=0 visible=true mode=fullscreen translucent=false sz=2} Visible recent tasks (most recent first): * RecentTaskInfo #0: id=1068 userId=0 hasTask=true lastActiveTime=109671463 baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=app.ericn.myapp/.MainActivity } baseActivity={app.ericn.myapp/app.ericn.myapp.MainActivity} topActivity={app.ericn.myapp/app.ericn.myapp.SecondActivity} realActivity={app.ericn.myapp/app.ericn.myapp.MainActivity} isExcluded=false activityType=standard windowingMode=fullscreen supportsSplitScreenMultiWindow=true supportsMultiWindow=true taskDescription { colorBackground=#ffffffff colorPrimary=#ff6200ee iconRes=/0 iconBitmap=false resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION minWidth=-1 minHeight=-1 colorBackgroundFloating=#ffffffff } lastSnapshotData { taskSize=Point(1080, 2280) contentInsets=Rect(0, 83 - 0, 132) bufferSize=Point(864, 1824) } ... ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities) Display #0 (activities from top to bottom): mResumedActivity: ActivityRecord{10684b5 u0 app.ericn.myapp/.SecondActivity t1068} RootTask #1068: type=standard mode=fullscreen isSleeping=false mBounds=Rect(0, 0 - 0, 0) mCreatedByOrganizer=false * Task{41d503 #1068 type=standard A=10287:app.ericn.myapp U=0 visible=true mode=fullscreen translucent=false sz=2} mBounds=Rect(0, 0 - 0, 0) mMinWidth=-1 mMinHeight=-1 userId=0 effectiveUid=u0a287 mCallingUid=2000 mUserSetupComplete=true mCallingPackage=com.android.shell mCallingFeatureId=null affinity=10287:app.ericn.myapp intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=app.ericn.myapp/.MainActivity} mActivityComponent=app.ericn.myapp/.MainActivity autoRemoveRecents=false isPersistable=true activityType=1 rootWasReset=false mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLE Activities=[ActivityRecord{da73511 u0 app.ericn.myapp/.MainActivity t1068}, ActivityRecord{10684b5 u0 app.ericn.myapp/.SecondActivity t1068}] askedCompatMode=false inRecents=true isAvailable=true mRootProcess=ProcessRecord{e2571b2 24749:app.ericn.myapp/u0a287} taskId=1068 rootTaskId=1068 hasChildPipActivity=false mHasBeenVisible=true mResizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION mSupportsPictureInPicture=false isResizeable=true lastActiveTime=109671463 (inactive for 3s) Hist #1: ActivityRecord{10684b5 u0 app.ericn.myapp/.SecondActivity t1068} Intent { cmp=app.ericn.myapp/.SecondActivity } ProcessRecord{e2571b2 24749:app.ericn.myapp/u0a287} Hist #0: ActivityRecord{da73511 u0 app.ericn.myapp/.MainActivity t1068} Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=app.ericn.myapp/.MainActivity } Resumed activities in task display areas (from top to bottom): Resumed: ActivityRecord{10684b5 u0 app.ericn.myapp/.SecondActivity t1068} ResumedActivity: ActivityRecord{10684b5 u0 app.ericn.myapp/.SecondActivity t1068}
5条答案
按热度按时间fcy6dtqo1#
要改进Paul的回答并查看与您的应用相关的数据,只有您可以:
jvlzgdj92#
使用下面的命令可以显示任务和活动的堆栈
结果是这样的:
wlzqhblo3#
如果只想查看活动堆栈,请使用以下设置命令
adb shell
垃圾场活动|grep-i运行
piztneat4#
您可以使用adb来实现此目的:
8dtrkrch5#
sham的回答很棒
但如果你想进一步缩小范围,我相信以下两节是最相关的: