简述
在 App 开发调试过程中,可能需要查看 App 的 Activity 栈用于校验 Activity 的跳转情况是否正确
查看 Activity 栈的操作步骤:
- 连接真机/模拟器
adb shell进入 Android 系统dumpsys activity activities查看 Activity 栈信息- 命令会输出所有正在运行中的 App 堆栈信息,查看之前需要关闭其他无关 App,否则输出信息太多
示例信息
// - adb shell 进入 Android 系统// 查看 Activity 栈信息HWVTR:/ $ dumpsys activity activitiesACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)Display #0 (activities from top to bottom):// 栈顶进程Stack #276: type=standard mode=fullscreenisSleeping=falsemBounds=Rect(0, 0 - 0, 0)Task id #1922mBounds=Rect(0, 0 - 0, 0)mMinWidth=-1mMinHeight=-1mLastNonFullscreenBounds=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.launcheraffinity=11146:com.emao.taochemaointent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.emao.taochemao/.activity.TestActivity}realActivity=com.emao.taochemao/.activity.TestActivityautoRemoveRecents=false isPersistable=true numFullscreen=1 activityType=1rootWasReset=true mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLEActivities=[ActivityRecord{34ac0dc u0 com.emao.taochemao/.activity.TestActivity t1922}]askedCompatMode=false inRecents=true isAvailable=truemRootProcess=ProcessRecord{f556f62 1340:com.emao.taochemao/u0a1146}stackId=276hasBeenVisible=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.taochemaolaunchedFromUid=10063 launchedFromPackage=com.huawei.android.launcher userId=0app=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.taochemaorealActivity=com.emao.taochemao/.activity.TestActivitybaseDir=/data/app/com.emao.taochemao-rOZiJbPodHnjB3hWsT3u1w==/base.apkdataDir=/data/user/0/com.emao.taochemaostateNotNeeded=false componentSpecified=true mActivityType=standardcompat={480dpi} labelRes=0x7f100042 icon=0x7f0d0000 theme=0x7f1100camLastReportedConfigurations: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=-2s797mshaveState=true icicle=nullstate=RESUMED stopped=false delayedResume=false finishing=falsekeysPaused=false inHistory=true visible=true sleeping=false idle=false mStartingWindowState=STARTING_WINDOW_SHOWNfullscreen=true noDisplay=false immersive=false launchMode=0frozenBeforeDestroy=false forceNewConfig=falsemActivityType=standarddisplayStartTime=-2s799ms startTime=0resizeMode=RESIZE_MODE_UNRESIZEABLEmLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=falsemaxAspectRatio=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=fullscreenisSleeping=falsemBounds=Rect(0, 0 - 0, 0)Task id #1mBounds=Rect(0, 0 - 0, 0)mMinWidth=-1mMinHeight=-1mLastNonFullscreenBounds=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=androidaffinity=10063:com.huawei.android.launcherintent={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.UniHomeLauncherautoRemoveRecents=false isPersistable=true numFullscreen=1 activityType=2rootWasReset=false mNeverRelinquishIdentity=true mReuseTask=false mLockTaskAuth=LOCK_TASK_AUTH_PINNABLEActivities=[ActivityRecord{2ec4195 u0 com.huawei.android.launcher/.unihome.UniHomeLauncher t1}]askedCompatMode=false inRecents=true isAvailable=truemRootProcess=ProcessRecord{df8f238 2321:com.huawei.android.launcher/u0a63}stackId=0hasBeenVisible=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.launcherlaunchedFromUid=0 launchedFromPackage=null userId=0app=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.launcherrealActivity=com.huawei.android.launcher/.unihome.UniHomeLauncherbaseDir=/system/app/HwLauncher6/HwLauncher6.apkdataDir=/data/user_de/0/com.huawei.android.launcherstateNotNeeded=true componentSpecified=false mActivityType=homecompat={480dpi} labelRes=0x7f0a00b4 icon=0x7f020223 theme=0x2060013mLastReportedConfigurations: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=-5d7h34m48s577mshaveState=false icicle=nullstate=PAUSED stopped=false delayedResume=false finishing=falsekeysPaused=false inHistory=true visible=false sleeping=false idle=true mStartingWindowState=STARTING_WINDOW_NOT_SHOWNfullscreen=true noDisplay=false immersive=false launchMode=2frozenBeforeDestroy=false forceNewConfig=falsemActivityType=homewaitingVisible=true nowVisible=false lastVisibleTime=-8s783msconnections=[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_RESIZEABLEmLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=falseRunning 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=2mHomeStack=ActivityStack{ab3c2ef stackId=0 type=home mode=fullscreen visible=false translucent=true, 1 tasks}isHomeRecentsComponent=true KeyguardController:mKeyguardShowing=falsemAodShowing=falsemKeyguardGoingAway=falsemOccluded=falsemDismissingKeyguardActivity=nullmDismissalRequested=falsemVisibilityTransactionDepth=0LockTaskControllermLockTaskModeState=NONEmLockTaskModeTasks=mLockTaskPackages (userId:packages)=u0:[]
