简述
在 App 开发调试过程中,可能需要查看 App 的 Activity 栈用于校验 Activity 的跳转情况是否正确
查看 Activity 栈的操作步骤:
- 连接真机/模拟器
adb shell
进入 Android 系统dumpsys activity activities
查看 Activity 栈信息- 命令会输出所有正在运行中的 App 堆栈信息,查看之前需要关闭其他无关 App,否则输出信息太多
示例信息
// - adb shell 进入 Android 系统
// 查看 Activity 栈信息
HWVTR:/ $ dumpsys activity activities
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Display #0 (activities from top to bottom):
// 栈顶进程
Stack #276: type=standard mode=fullscreen
isSleeping=false
mBounds=Rect(0, 0 - 0, 0)
Task id #1922
mBounds=Rect(0, 0 - 0, 0)
mMinWidth=-1
mMinHeight=-1
mLastNonFullscreenBounds=null
* TaskRecord{515d010 #1922 A=11146:com.emao.taochemao U=0 StackId=276 sz=1}
userId=0 effectiveUid=u0a1146 mCallingUid=u0a63 mUserSetupComplete=true mCallingPackage=com.huawei.android.launcher
affinity=11146:com.emao.taochemao
intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.emao.taochemao/.activity.TestActivity}
realActivity=com.emao.taochemao/.activity.TestActivity
autoRemoveRecents=false isPersistable=true numFullscreen=1 activityType=1
rootWasReset=true mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLE
Activities=[ActivityRecord{34ac0dc u0 com.emao.taochemao/.activity.TestActivity t1922}]
askedCompatMode=false inRecents=true isAvailable=true
mRootProcess=ProcessRecord{f556f62 1340:com.emao.taochemao/u0a1146}
stackId=276
hasBeenVisible=false mResizeMode=RESIZE_MODE_UNRESIZEABLE mSupportsPictureInPicture=false isResizeable=false lastActiveTime=544638619 (inactive for 2s)
// 进程内 Activity 栈详情信息
* Hist #0: ActivityRecord{34ac0dc u0 com.emao.taochemao/.activity.TestActivity t1922}
packageName=com.emao.taochemao processName=com.emao.taochemao
launchedFromUid=10063 launchedFromPackage=com.huawei.android.launcher userId=0
app=ProcessRecord{f556f62 1340:com.emao.taochemao/u0a1146}
Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.emao.taochemao/.activity.TestActivity bnds=[435,654][645,939] }
frontOfTask=true task=TaskRecord{515d010 #1922 A=11146:com.emao.taochemao U=0 StackId=276 sz=1}
taskAffinity=11146:com.emao.taochemao
realActivity=com.emao.taochemao/.activity.TestActivity
baseDir=/data/app/com.emao.taochemao-rOZiJbPodHnjB3hWsT3u1w==/base.apk
dataDir=/data/user/0/com.emao.taochemao
stateNotNeeded=false componentSpecified=true mActivityType=standard
compat={480dpi} labelRes=0x7f100042 icon=0x7f0d0000 theme=0x7f1100ca
mLastReportedConfigurations:
mGlobalConfig={1.0 ?mcc?mnc [zh_CN_#Hans] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 0, 0) mAppBounds=Rect(0, 0 - 1080, 1920) mWindowingMode=fullscreen mActivityType=undefined} nonFullScreen=0 suim:1 s.6}
mOverrideConfig={1.0 ?mcc?mnc [zh_CN_#Hans] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 1920) mAppBounds=Rect(0, 0 - 1080, 1920) mWindowingMode=fullscreen mActivityType=standard} nonFullScreen=0 suim:1 s.6}
CurrentConfiguration={1.0 ?mcc?mnc [zh_CN_#Hans] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 1920) mAppBounds=Rect(0, 0 - 1080, 1920) mWindowingMode=fullscreen mActivityType=standard} nonFullScreen=0 suim:1 s.6}
launchFailed=false launchCount=1 lastLaunchTime=-2s797ms
haveState=true icicle=null
state=RESUMED stopped=false delayedResume=false finishing=false
keysPaused=false inHistory=true visible=true sleeping=false idle=false mStartingWindowState=STARTING_WINDOW_SHOWN
fullscreen=true noDisplay=false immersive=false launchMode=0
frozenBeforeDestroy=false forceNewConfig=false
mActivityType=standard
displayStartTime=-2s799ms startTime=0
resizeMode=RESIZE_MODE_UNRESIZEABLE
mLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=false
maxAspectRatio=2.4
// 进程内 Activity 栈简略信息
Running activities (most recent first):
TaskRecord{515d010 #1922 A=11146:com.emao.taochemao U=0 StackId=276 sz=1}
Run #0: ActivityRecord{34ac0dc u0 com.emao.taochemao/.activity.TestActivity t1922}
mResumedActivity: ActivityRecord{34ac0dc u0 com.emao.taochemao/.activity.TestActivity t1922}
// 栈内第 2 进程
Stack #0: type=home mode=fullscreen
isSleeping=false
mBounds=Rect(0, 0 - 0, 0)
Task id #1
mBounds=Rect(0, 0 - 0, 0)
mMinWidth=-1
mMinHeight=-1
mLastNonFullscreenBounds=null
* TaskRecord{1a1e1d4 #1 A=10063:com.huawei.android.launcher U=0 StackId=0 sz=1}
userId=0 effectiveUid=u0a63 mCallingUid=1000 mUserSetupComplete=true mCallingPackage=android
affinity=10063:com.huawei.android.launcher
intent={act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000300 cmp=com.huawei.android.launcher/.unihome.UniHomeLauncher}
realActivity=com.huawei.android.launcher/.unihome.UniHomeLauncher
autoRemoveRecents=false isPersistable=true numFullscreen=1 activityType=2
rootWasReset=false mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLE
Activities=[ActivityRecord{2ec4195 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1}]
askedCompatMode=false inRecents=true isAvailable=true
mRootProcess=ProcessRecord{df8f238 2321:com.huawei.android.launcher/u0a63}
stackId=0
hasBeenVisible=true mResizeMode=RESIZE_MODE_RESIZEABLE mSupportsPictureInPicture=false isResizeable=true lastActiveTime=544638494 (inactive for 2s)
* Hist #0: ActivityRecord{2ec4195 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1}
packageName=com.huawei.android.launcher processName=com.huawei.android.launcher
launchedFromUid=0 launchedFromPackage=null userId=0
app=ProcessRecord{df8f238 2321:com.huawei.android.launcher/u0a63}
Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000300 cmp=com.huawei.android.launcher/.unihome.UniHomeLauncher }
frontOfTask=true task=TaskRecord{1a1e1d4 #1 A=10063:com.huawei.android.launcher U=0 StackId=0 sz=1}
taskAffinity=10063:com.huawei.android.launcher
realActivity=com.huawei.android.launcher/.unihome.UniHomeLauncher
baseDir=/system/app/HwLauncher6/HwLauncher6.apk
dataDir=/data/user_de/0/com.huawei.android.launcher
stateNotNeeded=true componentSpecified=false mActivityType=home
compat={480dpi} labelRes=0x7f0a00b4 icon=0x7f020223 theme=0x2060013
mLastReportedConfigurations:
mGlobalConfig={1.0 ?mcc?mnc [zh_CN_#Hans] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 0, 0) mAppBounds=Rect(0, 0 - 1080, 1920) mWindowingMode=fullscreen mActivityType=undefined} nonFullScreen=0 suim:1 s.6}
mOverrideConfig={1.0 ?mcc?mnc [zh_CN_#Hans] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 1920) mAppBounds=Rect(0, 0 - 1080, 1920) mWindowingMode=fullscreen mActivityType=home} nonFullScreen=0 suim:1 s.6}
CurrentConfiguration={1.0 ?mcc?mnc [zh_CN_#Hans] ldltr sw360dp w360dp h616dp 480dpi nrml long port finger -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 1920) mAppBounds=Rect(0, 0 - 1080, 1920) mWindowingMode=fullscreen mActivityType=home} nonFullScreen=0 suim:1 s.6}
OverrideConfiguration={0.0 ?mcc?mnc ?localeList ?layoutDir ?swdp ?wdp ?hdp ?density ?lsize ?long ?ldr ?wideColorGamut ?orien ?uimode ?night ?touch ?keyb/?/? ?nav/? winConfig={ mBounds=Rect(0, 0 - 0, 0) mAppBounds=null mWindowingMode=undefined mActivityType=home} nonFullScreen=0}
launchFailed=false launchCount=0 lastLaunchTime=-5d7h34m48s577ms
haveState=false icicle=null
state=PAUSED stopped=false delayedResume=false finishing=false
keysPaused=false inHistory=true visible=false sleeping=false idle=true mStartingWindowState=STARTING_WINDOW_NOT_SHOWN
fullscreen=true noDisplay=false immersive=false launchMode=2
frozenBeforeDestroy=false forceNewConfig=false
mActivityType=home
waitingVisible=true nowVisible=false lastVisibleTime=-8s783ms
connections=[ConnectionRecord{584bc23 u0 CR IMP WACT DEAD com.huawei.search/.services.overlay.LauncherOverlayService:@1d50152}, ConnectionRecord{fa5f9d2 u0 CR IMP WACT com.huawei.recsys/com.huawei.common.service.Decision:@a08fc5d}, ConnectionRecord{921f076 u0 CR IMP WACT com.huawei.search/.services.overlay.LauncherOverlayService:@1d50152}]
resizeMode=RESIZE_MODE_RESIZEABLE
mLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=false
Running activities (most recent first):
TaskRecord{1a1e1d4 #1 A=10063:com.huawei.android.launcher U=0 StackId=0 sz=1}
Run #0: ActivityRecord{2ec4195 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1}
mLastPausedActivity: ActivityRecord{2ec4195 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1}
Activities waiting to stop:
TaskRecord{1a1e1d4 #1 A=10063:com.huawei.android.launcher U=0 StackId=0 sz=1}
Stop #0: ActivityRecord{2ec4195 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1}
Activities waiting for another to become visible:
TaskRecord{1a1e1d4 #1 A=10063:com.huawei.android.launcher U=0 StackId=0 sz=1}
Wait #0: ActivityRecord{2ec4195 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1}
ResumedActivity: ActivityRecord{34ac0dc u0 com.emao.taochemao/.activity.TestActivity t1922}
mFocusedStack=ActivityStack{c0ea709 stackId=276 type=standard mode=fullscreen visible=true translucent=false, 1 tasks} mLastFocusedStack=ActivityStack{c0ea709 stackId=276 type=standard mode=fullscreen visible=true translucent=false, 1 tasks}
mCurTaskIdForUser={0=1922}
mUserStackInFront={}
displayId=0 stacks=2
mHomeStack=ActivityStack{ab3c2ef stackId=0 type=home mode=fullscreen visible=false translucent=true, 1 tasks}
isHomeRecentsComponent=true KeyguardController:
mKeyguardShowing=false
mAodShowing=false
mKeyguardGoingAway=false
mOccluded=false
mDismissingKeyguardActivity=null
mDismissalRequested=false
mVisibilityTransactionDepth=0
LockTaskController
mLockTaskModeState=NONE
mLockTaskModeTasks=
mLockTaskPackages (userId:packages)=
u0:[]