安装 apk 到手机
adb install aa.apk
参数:
- -r:覆盖安装
- -s:将应用安装到 SD 卡
- -d:允许降级覆盖
卸载
adb uninstall com.sample.xx
将电脑上的文件复制到手机
例:将文件复制到 SD 卡的根目录
adb push aa.txt /sdcard
将手机上的文件复制到电脑上
例:将手机 SD 卡根目录下的 aa.txt 复制到电脑的某个目录下。
adb pull /sdcard/aa.txt /Users/eric/Downloads
查看当前运行的 Activity
adb shell "dumpsys activity top | grep ACTIVITY | tail -n 1"
- dumpsys activity top :打印顶层Activity信息
- grep ACTIVITY:从上个命令结果中过滤出Activity相关信息
- tail -n 1:从上一步过滤结果中继续过滤出最后一条记录,也就是当前界面(顶层top)activity
查看当前界面 Fragment
adb shell "dumpsys activity top | grep '#[0-9]: ' | tail -n 1"
清除应用数据与缓存
adb shell pm clear com.sample.xxx
通过 deeplink 打开应用
adb shell am start -W -a android.intent.action.VIEW -d "具体的deeplink地址" packageName
操作剪贴板
安装 APK:clipper
下载地址:https://github.com/majido/clipper
启动剪贴板 service
adb shell am startservice ca.zgrs.clipper/.ClipboardService
设置剪贴板内容
adb shell am broadcast -a clipper.set -e text "具体内容"
获取剪贴板内容
adb shell am broadcast -a clipper.get
在输入框输入文本
adb shell input text hello