您的位置:首页 > 移动开发 > Android开发

Android ADB 一些常用命令

2017-11-30 16:20 260 查看
查看目前连接的设备 
adb devices


安装应用 
adb install [your apk path]
 
adb install -r [your apk path] //强制安装
 

例如:
adb install Desktop/test.apk


复制文件到sdcard中 
adb push [your file path] [your dest path in sdcard]
 

例如:
adb push Desktop/test.txt /sdcard/


拉取sdcard中的文件 
adb pull [your file path in sdcard] [your dest path]
 

例如:
adb pull /sdcard/test.txt Desktop/


查看手机中安装的应用包名 
adb shell pm list packages
 

当然,可用通过grep进行过滤 

例如:
adb shell pm list packages | grep "ABC" // 包名包含ABC三个字母


模拟手机输入 
adb shell input keyevent [keycode]
 

例如:
adb shell input keyevent 3 // 模拟按下home键(其他按键可以自行搜索)


宁波整形医院http://www.zuanno.com/

宁波好的整形医院http://www.zuanno.com/


模拟触摸事件 

adb shell input [source]
 

例如:
adb shell input tap 100 100 // 模拟点击(100,100)
 

例如:
adb shell input touchscreen swipe 5 100 500 100 // 模拟从(5,100)滑动到(500,100)
 

关于source以及相关到其他命令,各位可以自行查阅资料

查看Activity的运行状态 
adb shell dumpsys activity
 

当然,可用通过grep进行过滤 

例如:
adb shell dumpsys activity | grep "ABC" // 过滤ABC关键字
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: