常用的adb指令

来源:互联网 发布:淘宝省钱群是真的吗 编辑:程序博客网 时间:2024/06/07 11:38

开启adb服务:adb start-service
终止adb服务:adb kill-service

安装apk:adb install xxx.apk
卸载apk:adb uninstall apk包名

查看连接的设备:adb devices
查看屏幕分辨率:adb shell wm size

启动Activity:adb shell am start -n 包名/Activity完整包名地址
如:adb shell am start -n com.example.testapp/com.example.testapp.MainActivity
关闭Activity:adb shell am force-stop 包名
如:adb shell am force-stop com.example.testapp

启动Service:adb shell am startservice -n 包名/service完整包名地址
Ps: 有时报”Requires permission not exported from uid 10257”的错误,要在注册Service中加一句android:exported=”true”
关闭Service:adb shell am stopservice -n 包名/service完整包名地址

发送广播:adb shell am broadcast -a android.intent.action.ActionName
如发送usb状态变化的广播:adb shell am broadcast -a android.hardware.usb.action.USB_STATE