adb devices
启动成功:android
以下图所示,/以前的就是package,以后的就是当前的activity。对于大多数的App,这个当前的activity就是am命令须要的launch activity, 但也有些应用启动时包含了欢迎页之类的,在你打开App的时候就自动切换了activity,那用这种方法就获取不了须要的package。shell
#查看当前app的入口 adb shell dumpsys window windows | findstr "Current"
#打开App方式 1 #com.ss.android.ugc.aweme/com.s... 这个是上面获取到的 adb shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.ss.android.ugc.aweme/com.ss.android.ugc.aweme.splash.SplashActivity #打开方式2 adb shell am start -n com.ss.android.ugc.aweme/com.ss.android.ugc.aweme.splash.SplashActivity
# 杀死全部服务 adb kill\-server
# HOME 键 adb shell input keyevent 3
# 返回键 adb shell input keyevent 4
# 滑动 adb shell input swipe 300 1000 300 500 # 参数 `300 1000 300 500` 分别表示`起始点x坐标 起始点y坐标 结束点x坐标 结束点y坐标`。
# 在焦点处于某文本框时,能够经过 `input` 命令来输入文本。 adb shell input text hello
# 屏幕点击 adb shell input tap x y
借鉴windows
adb input命令介绍
adb 打开和关闭应用