获取当前activity的名字
adb shell dumpsys activity | findstr "mFocusedActivity"
启动activity
adb shell am start -n {包(package)名}/{包名}.{活动(activity)名称}
例子:adb shell am start -n com.test.hello/.MainActivity
启动apk
adb shell am start com.test.hello
强制停止
adb shell am force-stop com.test.hello
清除缓存
adb shell pm clear com.test.hello
卸载apk(适用于/data/app 下的,一般用户安装的都在这个下面)
adb uninstall com.test.hello
卸载apk(适用于/system/app 下面,系统预装的app.需要root 权限或者是手机的eng 版本)
1 adb remount
2 rm /system/app/com.test.hello
安装
adb install com.test.hello
强制安装
com.test.hello
模拟按键输入
adb shell input keyevent 4
在屏幕上做划屏操作,前四个数为坐标点,后面是滑动的时间(单位毫秒)
adb shell input swipe 50 250 250 250 500
在屏幕上点击坐标点x=50 y=250的位置。
adb shell input tap 50 250
输入字符abc
adb shell input text abc
更多模拟输入
http://blog.csdn.net/jlminghui/article/details/39268419
抓取log
adb shell logcat -v threadtime | grep xxx
或者是输入到文件
adb shell logcat -v threadtime > d:/1.txt
获取bugreport (包括内存分配,cpu使用情况,按键分发,组件状态,虚拟内存状态)
adb shell bugreport > d:/1.txt
获取traces
adb pull /data/anr/traces.txt
adb 远程调试
1 adb tcpip 5555
2 adb connect ip.5555
断开远程调试
adb disconnect
查看设备
adb devices
多个设备连接时指定设备 设备ID从上一个命令得来。
adb -s 设备ID shell
实际上所有的的adb 命令都可以通过 -s 设备ID 的方式访问多个设备连接时的指定设备。