【1】常用命令
【2】通过网络连接adb
【3】adb 命令操作蓝牙
【1】常用命令
参考链接
Android 调试桥 (adb)
#查看当前连接设备
adb devices
adb -s 设备号 其他指令 #如果发现多个设备
#查看顶部Activity
adb shell dumpsys activity | findstr "mFocusedActivity" #windows环境下
adb shell dumpsys activity | grep "mFocusedActivity" #Linux、Mac环境下
#查看日志:
adb logcat
#安装apk文件:
adb install xxx.apk #如果已经存在,无法安装;
adb install -r xxx.apk #覆盖安装
adb install -r -t xxx.apk #比分直接RUN出来的包是test-onlu的无法安装,推荐使用**-t**
#卸载App:
adb uninstall com.zhy.app
adb uninstall -k com.zhy.app #如果想要保留数据
#查看手机端安装的所有app包名:
adb shell pm list packages
#传递文件:
adb push 文件名 手机端SDCard路径 #往手机SDCard传递文件
adb pull 手机端文件路径 本地保存路径
【2】通过网络连接adb
1. 命令行输入:adb connect 172.16.4.37:5555 (:5555可省略)
提示:unable to connect to 172.16.4.37:5555
解决办法:
1)手机与PC相连,执行以下命令:adb tcpip 5555
成功提示:restarting in TCP mode port 5555
如果手机没有和PC连接,直接使用以上命令会提示 error:device not found
然后断开USB
2)接着执行adb connect 172.16.4.37:5555,这时候应该就能连接成功了
成功提示:connected to 172.16.4.37:5555
【3】adb 命令操作蓝牙
#打开和关闭蓝牙BT:
adb root
adb shell svc bluetooth enable
adb shell svc bluetooth disable
#查询蓝牙开启状态:
adb shell settings get global bluetooth_on
=》0: 未开启 1: 已开启
#获取mac地址:
#方法1:
adb shell settings get secure bluetooth_address
=》如:00:00:00:00:00:01
#方法2:
adb shell adb shell service call bluetooth_manager 13 #其中: bluetooth_manager: [android.bluetooth.IBluetoothManager] 是 Bluetooth 相关 services 提供给上层的接口。13 是IBluetoothManager接口中的第13个方法:String getAddress();(注:该值不同平台可能不一样,最终根据IBluetoothManager.aidl确定。 在/system/bt/binder/android/bluetooth/ 或 /frameworks/base/core/java/android/bluetooth/下)