android开发笔记之ADB Shell Commands

android开发笔记之ADB Shell Commands_第1张图片

对于android开发来说,adb shell 命令是我们经常使用的开发命令,下面对这些常用的关键adb shell 命令进行一些说明。

adb shell 命令的官方网站

https://developer.android.com/studio/command-line/shell.html#othershellcommands

adb shell 命令的官方网站,如果对于adb shell命令有任何问题,可以去android官网去查看权威的说明。

Using activity manager (am)

启动activity

adb shell am start -a android.intent.action.VIEW
adb shell am start  com.example.appinfomanagertinno/.MainActivity

启动service

adb shell am startservice -a com.lt.test.action.ONESERVICE
adb shell am startservice com.android.music/.MediaPlaybackService

启动广播

adb shell am broadcast -a android.intent.action.MASTER_CLEAR(恢复出厂设置的方法,会清除内存所有内容)
adb shell am broadcast -n com.lt.test/.MyBroadcast

关闭一个应用:

adb shell am force-stop com.example.appinfomanagertinno

关闭所有的后台进程

adb shell am kill-all

Using package manager (pm)

查看所有packages:

adb shell pm list packages

查看特定的packages:

adb shell pm list packages | grep tinno
package:com.applock.tinno
package:com.tinno.simmelock
package:com.tinno.gesture.phone
package:com.tinno.engineermode
package:com.tinno.lanixcodes
package:com.tinno.smartpowersaver
package:com.tinno.gps
package:com.tinno

查看package的apk位置:

adb shell pm path com.applock.tinno
package:/system/app/applock_tinno/applock_tinno.apk

删除一个apk:

adb shell pm uninstall com.example.MyApp

查看所有的features:

adb shell pm  list features

查看最多支持几个用户:

adb shell pm  get-max-users
Maximum supported users: 4

查看手机上所有的user信息:

adb shell pm list users

查看手机所有的permissions:

adb shell pm  list permissions

清除package所有的相关数据:

adb shell pm clear <PACKAGE>

比如清除launcher所有的数据:

adb shell pm clear com.ape.launcher3
Success

手机截图:

adb shell screencap /sdcard/screen.png

或者:

$ adb shell
shell@ $ screencap /sdcard/screen.png
shell@ $ exit
$ adb pull /sdcard/screen.png

手机录像:

$ adb shell screenrecord /sdcard/demo.mp4

你可能感兴趣的:(android,shell)