Android控制台命令am简介

Android在shell中提供了 am 命令来发送Intent,它的源码为位于 frameworks/base/cmds/am.
它本身是用JAVA代码来实现的。
执行 am 命令其实是通过运行shell脚本 frameworks/base/cmds/am/am,然后在该脚本中运行 app_process 命令来启动am这个java程序的。
frameworks/base/cmds/am/am脚本文件如下:
 
   

# Script to start "am" on the device, which has a very rudimentary
# shell.
#
base=/system
export CLASSPATH=$base/framework/am.jar
exec app_process $base/bin com.android.commands.am.Am "$@"

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]
        []
结束

你可能感兴趣的:(Android控制台命令am简介)