1.获取主(要启动的)Activity和包名
dumpsys window w | grep mCurrent # 可直接获取系统应用
dumpsys activity | grepmFocusedActivity # 主要 针对第三方应用
dumpsys window windows | findstr “Current” # 主要 针对第三方应用
2.启动app
- 命令行输入 adb shell am start +包名/.Activity (要启动的Activity)
例如:adb shell am start com.android.settings/.HWSettings
- 命令行中输入adb shell am start -W -n 包名/.Activity
例如:adb shell am start -W -n com.android.settings/.Settings$ApnEditorActivity
3. 关闭App
- cmd命令行中执行 adb shell am force-stop app包名
例如:adb shell am force-stop com.android.settings关闭系统设置;
- cmd命令行中执行 adb shell pm clear app包名
例如adb shell pm clear app com.android.settings 关闭系统设置