设备连接状态
adb devices
OS版本
adb shell getprop ro.build.version.release
进入shell
adb shell
多个设备连接时,需要-s 指定设备id
adb -s <DeviceID> shell
监控Activity状态
adb shell am monitor
例如
adb shell am monitor
Monitoring activity manager... available commands:
(q)uit: finish monitoring
** Activity starting: com.android.chrome
** Activity starting: com.android.chrome
** Activity starting: com.android.systemui
** Activity starting: com.google.android.googlequicksearchbox
打印logcat
adb logcat
屏幕分辨率
adb shell wm size
安装APK
adb install <APK file path>
覆盖安装高版本时,使用-r
卸载APK
adb uninstall <APK file path>
※ chromeを例にしてコマンドを説明すると
启动APP
以chrome为例
adb shell am start \
-n com.android.chrome/com.google.android.apps.chrome.Main
指定URL启动chrome
adb shell am start \
-a android.intent.action.VIEW \
-n com.android.chrome/com.google.android.apps.chrome.Main \
-d http://www.google.com/
-a <Intent>
-n <Package name>/.<Activity name>>
-d <URL>
发送广播
adb shell am broadcast -a <Intent>
例如,低电量的系统广播
adb shell am broadcast -a android.intent.action.BATTERY_LOW
重启完成的系统广播
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
清除APP缓存
adb shell pm clear com.android.chrome
结束进程
adb shell am force-stop com.android.chrome
已安装APP列表
adb shell pm list packages
已启动的Activity信息
adb shell dumpsys activity activities
导出文件
adb pull sdcard/works/hello.sh .
导入文件
adb push hello.sh /sdcard/works/
输入文字
向当前焦点控件输入文字,例如EditText
adb shell input <text message>
输入键盘事件
adb shell input keyevent 3