Android开发工具—adb shell命令

来源:互联网 发布:夏老师c语言是谁 编辑:程序博客网 时间:2024/06/04 18:12

由于adb命令目前找不到全面详细的教程,本文只是罗列出比较常用的命令,记录一下。

1、adb shell

进入shell模式,可在手机里执行shell命令

若获取手机root权限,su命令即可切换到root角色下

adb shell shellCommand
不进入shell模式,直接执行shellCommand指令,如adb shell ls

2、adb shell svc wifi disable #关闭WiFi连接

adb shell svc data disable #关闭数据流量

(svc help)

3、adb shell am start -n com.example.test/.Helloworld
启动包名为com.example.test的应用入口activity即com.example.test.Helloworld

adb shell am force-stop com.example.test
强制关闭包名为com.example.test的应用

adb shell am kill com.example.test
杀死包名为com.example.test的应用进程

adb shell am kill-all
杀死所有的后台进程

4、adb shell pm list packages
列出设备上安装的所有应用的包名
-f 可显示应用对应的文件
-d 只显示被禁用的应用
-e 只显示启用的应用
-s 只显示系统应用
-3 只显示第三方应用
-i 显示应用安装的方式

adb shell pm list features
列出系统所支持的功能,如蓝牙、相机、定位等

adb shell pm path com.example.test
显示com.example.test的apk路径

adb shell pm clear com.example.test
删除和com.example.test相关的数据

adb shell pm enable com.example.test
启用应用com.example.test

adb shell pm disable com.example.test
禁用应用com.example.test

adb shell pm get-install-location
查看系统默认的安装方式,0 [auto]是系统自动决定安装位置,1 [internal]是安装在系统内部存储空间,2 [external]是安装在外置存储卡上

5、adb shell screenrecord /sdcard/demo.mp4
录制屏幕并保存为demo.mp4。该功能只能在Android 4.4(API level 19)或更高的版本运行。按Ctrl-C停止录制,否则在3分钟后自动停止录制。可通过--time-limit 30设置录制时间为30秒。


参考链接:

http://cashow.github.io/Android-developer-tools-adb-command.html

http://blog.csdn.net/gb112211/article/details/33073191

https://testerhome.com/topics/1462

0 0
原创粉丝点击