-
查看最顶端应用的包名和activity名
adb shell dumpsys window | grep mCurrentFous -
操作指定设备
# push 文件到指定设备的 /sdcard/中 adb -s 设备id push aa.dex /sdcard/ -
查看手机log信息
# 打印log adb logcat -i color
ADB 控制指令
-
输入命令(input)
adb shell input "111"- 特殊字符需要特殊的字符需要使用keyevnet
-
模拟屏幕滑动(swip)
adb shell input swipe 100 200 500 600 900 #从(100,200)滑动到(500,600)总花费900ms -
点击(tag)
adb shell input tap 20 1000 # 点击(20, 100) -
长按(swip)
adb shell input swipe 1400 400 1400 400 900 # 长按(1400,400) 900ms -
事件触发(keyevent)more
adb shell input keyevent 7 # for key '0' adb shell input keyevent 8 # for key '1' adb shell input keyevent 29 # for key 'A' adb shell input keyevent 54 # for key 'B' adb shell input keyevent 26 # 电源键解锁手机:
adb shell input keyevent 26 && adb shell input swipe 250 250 800 800截屏:adb exec-out screencap -p > 1.png
adb shell screencap -p /sdcard/screen.png && adb pull /sdcard/screen.png /tmp/ && adb shell rm /sdcard/screen.png && open file:/tmp/screen.pngMonkey点击
adb shell monkey -p com.example.agsdkdemo 10000 -s500 -v自动化测试
adb shell am instrument -w com.example.agsdkdemo.test/android.test.InstrumentationTestRunner获取厂商机型等
adb shell getprop | grep product根据APK获取应用包名、权限配置等信息(配合grep)
$ANDROID_HOME/build-tools/android-4.4/aapt d badging直接拉起应用
adb shell am start -n com.example.wegame/com.example.wegame.MainActivity退出应用
adb shell am force-stop com.example.wegame开启/关闭wifi
adb shell svc wifi enable adb shell svc wifi disable