本文adb 命令分为三部分进行介绍:adb 命令adb shell 命令linux 命令

adb 命令

这里介绍一些最常用的命令:

1、adb connect 远程连接 Android 设备

2、adb devices , 获取设备列表及设备状态

     adb get-state , 获取设备的状态

  device:设备正常连接
  offline:连接出现异常,设备无响应
  unknown:没有连接设备

3、adb kill-server , 结束 adb 服务

4、adb start-server ,  启动 adb 服务

5、adb logcat , 打印 Android 的系统日志

6、adb bugreport , 打印dumpsys、dumpstate、logcat的输出,用于分析错误

adb bugreport > d:\bugreport.log

7、adb install , 安装应用,覆盖安装是使用 -r 选项

8、adb uninstall , 卸载应用,-k 选项,卸载时保存数据和缓存目录

9、adb pull , 将 Android 设备上的文件或者文件夹复制到本地

adb pull sdcard/pull.txt d:\
如果需要重命名为 rename.txt:
adb pull sdcard/pull.txt d:\rename.txt

10、adb push , 推送本地文件至 Android 设备

adb push d:\push.txt sdcard/

11、adb reboot , 重启 Android 设备

12、adb forward , 将 宿主机上的某个端口重定向到设备的某个端口

adb forward tcp:1314 tcp :8888   执行该命令后所有发往宿主机 1314 端口的消息、数据都会转发到 Android 设备的 8888 端口上,因此可以通过远程的方式控制 Android 设备。

adb  shell 命令

adb 命令是 adb 这个程序自带的一些命令,而 adb shell 则是调用的 Android 系统中的命令,这些 Android 特有的命令都放在了 Android 设备的 system/bin 目录下。

在连接模拟器的情况下,dos输入:adb shell即可进入安卓系统的跟目录下,也可以这样编写:adb  shell ls 即查看跟目录

PM:

1、pm list package 列出安装在设备上的应用

-s:列出系统应用

-3:列出第三方应用

-f:列出应用包名及对应的apk名及存放位置

-i:列出应用包名及其安装来源

例如,查找三方应用中知乎的包名、apk存放位置、安装来源:adb shell pm list package -f -3 -i zhihu

2、pm path 列出对应包名的 .apk 位置

adb shell pm path com.tencent.mobileqq

3、pm dump , 后跟包名,列出指定应用的 dump 信息,里面有各种信息

adb shell pm dump com.tencent.mobileqq

4、pm install , 安装应用

目标 apk 存放于 Android 设备上,用 pm install 安装

5、pm uninstall , 卸载应用,同 adb uninstall

6、pm clear , 清除应用数据

7、pm set-install-location , pm get-install-location , 设置应用安装位置,获取应用安装位置

[0/auto]:默认为自动
[1/internal]:默认为安装在手机内部
[2/external]:默认安装在外部存储

AM:

1、am start , 启动一个 Activity

  启动相机:

 adb shell am start -n com.android.camera/.Camera

 Starting: Intent { cmp=com.android.camera/.Camera }

  先停止目标应用,再启动

 adb shell am start -S com.android.camera/.Camera

 Stopping: com.android.camera

 Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.camera/.Camera }

  等待应用完成启动

 adb shell am start -W com.android.camera/.Camera

Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.camera/.Camera }Status: okActivity: com.android.camera/.CameraThisTime: 500TotalTime: 500Complete

启动默认浏览器打开一个网页
adb shell am start -a android.intent.action.VIEW -d http://testerhome.com
Starting: Intent { act=android.intent.action.VIEW dat=http://testerhome.com }

启动拨号器拨打 10086
adb shell am start -a android.intent.action.CALL -d tel:10086            Starting: Intent { act=android.intent.action.CALL dat=tel:xxxxx }

2、input text , 发送文本内容,不能发送中文

adb shell input text test123456

3、input keyevent , 发送按键事件

adb shell input keyevent 3   #模拟按home键

screencap

截图:

adb shell screencap -p /sdcard/screen.png

 

 

linux 命令

常用到的命令,只列出:

cat、cd、chmod、cp、date、df、du、grep、kill、ln、ls、lsof、netstat、ping、ps、rm、rmdir、top、touch、重定向符号 ">" ">>"、管道 "|"

 

 

更多相关文章

  1. cocos编译android命令
  2. 关于用代码实现android设备的重启
  3. android的m、mm、mmm编译命令的使用简介
  4. android应用程序logcat命令
  5. Android手机隐藏命令大全
  6. 【源码】实现Android闹钟功能使用HTML+JS,并附带Alarm代码分享
  7. 解决打开Android(安卓)SDK Manager时出现“.....\sdk\tools\l
  8. Android(安卓)adb 使用详解(一)
  9. 【android学习】getevent和sendevent

随机推荐

  1. 在Android中使用Gradle
  2. Mac os Android 源码开发环境搭建
  3. unity游戏在安卓按home或者锁屏键后不能
  4. android 实现拖动效果
  5. getActionBar() return null
  6. android 通过构造创建进度对话框
  7. android 设置应用程序装在T卡的方法
  8. Android中使用自定义view实现轮播图
  9. Android 跳转到应用市场,评价App
  10. android 的 setTag