1.冷启动
冷启动:后台没有该应用程序的进程,应用首次启动。
获取package名
打开APP,然后使用命令
adb shell dumpsys activity | grep mFocusedActivity
adb shell logcat | grep START
adb shell logcat | grep cmp=
adb shell dumpsys activity | findstr mFocusedActivity mFocusedActivity: ActivityRecord{6468932 u0 com.android.contacts/.activities.PeopleActivity t156}
adb shell logcat | findstr START 03-09 22:45:57.809 1637 2939 E ActivityTaskManager: START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10600000 hwFlg=0x10 cmp=com.lingkou.leetcode/com.lingkou.main.splash.SplashActivity bnds=[648,1619][858,1968] (has extras)} result: 2
启动APP:
adb shell am start -W -n <package/activity>
adb shell am start -W -n com.android.contacts/.activities.PeopleActivity Starting: Intent { cmp=com.android.contacts/.activities.PeopleActivity } Status: ok Activity: com.android.contacts/.activities.PeopleActivity ThisTime: 334 TotalTime: 334 WaitTime: 375 Complete
停止APP:
adb shell am force-stop package
2.热启动
热启动:后台已经有了该程序的进程(返回,home键退出让应用程序在后台继续执行)当再次点开APP马上能够恢复到上次使用的状态,不需要再回到手机的首页打开应用程序。
adb shell input keyevent 3(home键)
adb shell input keyevent 4(返回)
参考:
https://blog.csdn.net/gufenchen/article/details/91410667
https://www.cnblogs.com/zhangwei-qianqian/p/11887627.html
https://blog.csdn.net/h_bpdwn/article/details/91425599