android 常用的adb命令

  1. 显示最上层Activity的名字
    adb shell dumpsys activity | findstr "mFocusedActivity" 
  2. 启动一个activity
    adb shell am start -n com.example.test.testactivtiy/com.example.test.testactivtiy.MainActivity
  3. 发送一个广播
    adb shell am broadcast -a com.android.test -n com.flycom.testvedio/com.flycom.testvedio.MyReceiver --es test_string "this is test string" --ei test_int 100 --ez test_boolean true
  4. 启动一个service
    adb shell am startservice -n com.example.ledstest/com.example.ledstest.RgbLedsService
    
    adb shell am start-foreground-service -n com.flycom.ledtest/com.flycom.ledtest.RgbLedsService
  5. 给应用权限
    有些权限不能通过这个方式给

    adb shell pm grant com.android.launcher3 android.permission.WRITE_SECURE_SETTINGS
  6. wm的使用
    adb shell wm size 查看分辨率
    adb shell wm size 1080x1920 修改分辨率
    adb shell wm size reset 恢复默认的分辨率
    adb shell wm density 480 修改density
    adb shell wm overscan LEFT,TOP,RIGHT,BOTTOM ,四个参数分别是显示边缘距离LCD左、上、右、下的像素数

  7. 获取和修改android.provider.Settings中的值
    注意这里有三种不同的值 system/global/secure
    adb shell settings get system/global/secure key 
    adb shell settings put system/global/secure key value

猜你喜欢

转载自blog.csdn.net/qq_32072451/article/details/82107503