adb shell am 的用法
16lz
2021-01-25
adb shell am 的功能
adb shell am 使用此命令可以从cmd控制台启动 activity, services;发送 broadcast等等:
C:\Users\Administrator>adb shell am
usage: am [subcommand] [options]
start an Activity: am start [-D] [-W]
-D: enable debugging
-W: wait for launch to complete
start a Service: am startservice
send a broadcast Intent: am broadcast
start an Instrumentation: am instrument [flags]
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-e : set argument to
-p: write profiling data to
-w: wait for instrumentation to finish before returning
start profiling: am profile start
stop profiling: am profile stop
start monitoring: am monitor [--gdb]
--gdb: start gdbserv on the given port at crash/ANR
specifications include these flags:
[-a ] [-d] [-t ]
[-c [-c ] ...]
[-e|--es ...]
[--esn ...]
[--ez ...]
[-e|--ei ...]
[-n] [-f ]
[--grant-read-uri-permission] [--grant-write-uri-permission]
[--debug-log-resolution]
[--activity-brought-to-front] [--activity-clear-top]
[--activity-clear-when-task-reset] [--activity-exclude-from-recents]
[--activity-launched-from-history] [--activity-multiple-task]
[--activity-no-animation] [--activity-no-history]
[--activity-no-user-action] [--activity-previous-is-top]
[--activity-reorder-to-front] [--activity-reset-task-if-needed]
[--activity-single-top]
[--receiver-registered-only] [--receiver-replace-pending]
[]
使用实例: 如启动一个 Activity:
格式: adb shell am start -n 包名/包名+类名(-n 类名,-a action,-d date,-m MIME-TYPE,-c category,-e 扩展数据,等)。 实例1: C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera
Starting: Intent { cmp=com.android.camera/.Camera }
实例2:(带extra 的 intent) C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera -e abc hello
Starting: Intent { cmp=com.android.camera/.Camera (has extras) } 其中 extra 的 key 为 abc ,value 为字串 "hello"
还可以发送命令模拟手机低电环境:
adb shell am 使用此命令可以从cmd控制台启动 activity, services;发送 broadcast等等:
C:\Users\Administrator>adb shell am
usage: am [subcommand] [options]
start an Activity: am start [-D] [-W]
-D: enable debugging
-W: wait for launch to complete
start a Service: am startservice
send a broadcast Intent: am broadcast
start an Instrumentation: am instrument [flags]
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-e
-p
-w: wait for instrumentation to finish before returning
start profiling: am profile
stop profiling: am profile
start monitoring: am monitor [--gdb
--gdb: start gdbserv on the given port at crash/ANR
[-a ] [-d
[-c
[-e|--es
[--esn
[--ez
[-e|--ei
[-n
[--grant-read-uri-permission] [--grant-write-uri-permission]
[--debug-log-resolution]
[--activity-brought-to-front] [--activity-clear-top]
[--activity-clear-when-task-reset] [--activity-exclude-from-recents]
[--activity-launched-from-history] [--activity-multiple-task]
[--activity-no-animation] [--activity-no-history]
[--activity-no-user-action] [--activity-previous-is-top]
[--activity-reorder-to-front] [--activity-reset-task-if-needed]
[--activity-single-top]
[--receiver-registered-only] [--receiver-replace-pending]
[
使用实例: 如启动一个 Activity:
格式: adb shell am start -n 包名/包名+类名(-n 类名,-a action,-d date,-m MIME-TYPE,-c category,-e 扩展数据,等)。 实例1: C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera
Starting: Intent { cmp=com.android.camera/.Camera }
实例2:(带extra 的 intent) C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera -e abc hello
Starting: Intent { cmp=com.android.camera/.Camera (has extras) } 其中 extra 的 key 为 abc ,value 为字串 "hello"
还可以发送命令模拟手机低电环境:
实例:
adb shell am broadcast -a android.intent.action.BATTERY_CHANGED --ei "level" 3 --ei "scale" 100
更多相关文章
- GitHub 标星 2.5K+!教你通过玩游戏的方式学习 VIM!
- 如何在后台运行Linux命令?
- No.11 使用firewall配置的防火墙策略的生效模式
- 使用Android(安卓)Studio编译Fresco
- Android(安卓)后台任务(四)Loader
- Ubuntu 14.04下搭建 Android(安卓)开发环境(1) -JDK安装
- 深入了解Android图形管道-part1
- android新增语言的方法(墨西哥的西班牙语)
- android 系统启动过程中加入tcpdump和logcat