adb常用指令

修改adb 5555默认端口
device/rockchip/common/rootdir/init.rk30board.rc

-    setprop service.adb.tcp.port 5555

+    setprop service.adb.tcp.port 6868

 

获取Android当前运行最顶层的activity
7.0
Windows:

adb shell dumpsys activity activities | findstr mFocusedActivity
adb shell dumpsys activity | findstr ResumedActivity


Linux:

adb shell dumpsys activity activities | grep mFocusedActivity


8.0
Android 8.0 现象:

改用:

Windows:

adb shell dumpsys activity activities | findstr mResumedActivity
adb shell dumpsys activity | findstr ResumedActivity
 

 adb shell dumpsys package 包名 |grep -i path

Linux:

adb shell dumpsys activity activities | grep mResumedActivity
dumpsys activity activities | grep topResumedActivity

截屏
adb shell /system/bin/screencap -p /sdcard/screenshot.png&adb pull /sdcard/screenshot.png E:\screenpCap\

屏幕录制
adb shell screenrecord /sdcard/test.mp4
#导出到电脑中(记得先在电脑建立一个文件)
adb pull  /sdcard/test.mp4 D:\123\test.mp4


#模拟滑动
向左滑动
adb shell input swipe 800 300 200 300
向右滑动
adb shell input swipe 200 300 800 300
向上滑动
adb shell input swipe 300 800 300 200
向下滑动
adb shell input swipe 300 200 300 800
#模拟点击
adb shell input tap 250 250
#模拟点击home键
adb shell input keyevent 3


APP安装位置
adb shell pm list packages -f |findstr com.sec.android.app.camera


发送广播
adb shell am broadcast -a 广播名android.intent.action.BOOT_COMPLETED
这条命令可以更精确的发送到某个package,如下:
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name

启动activity/service
在adb shell中,通过am命令行启动一个Activity程序:
从superuser源代码中摘录一段使用示例:
adb shell am start -a android.intent.action.MAIN -n com.koushikdutta.superuser/com.koushikdutta.superuser.SuperuserRequestActivity
这个示例中:
-a 表示action (android.intent.action.MAIN)
-n 表示packagename (com.koushikdutta.superuser)
SuperuserRequestActivity是对应的Activity name
关机
adb shell am broadcast -a android.intent.action.ACTION_SHUTDOWN -c android.intent.category.HOME -n com.andy.androidtest/.ShutdownBroadcastReceiver
恢复出厂设置
adb shell am broadcast -a android.intent.action.MASTER_CLEAR

10.0可以用下方法
1、
adb shell am broadcast -a android.intent.action.MASTER_CLEAR
adb shell "echo "--wipe_data\n--locale=en_US" > /cache/recovery/command"
adb shell setprop sys.powerctl reboot,recovery

2、
am broadcast -a android.intent.action.FACTORY_RESET -p android --es android.intent.extra.REASON MasterClearConfirm

禁用自动旋转
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0

旋转屏幕
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
i后面跟的不同的值代表旋转为不同的方向,取值范围为0,1,2,3
settings put system user_rotation 3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值