adb shell am命令大全

2016-07-13 16:32 暂无评论
  1. >adb shell am  
  2. usage: am [subcommand] [options]  
  3. usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]  
  4.                [--R COUNT] [-S] [--opengl-trace]  
  5.                [--user <USER_ID> | current] <INTENT>  
  6.        am startservice [--user <USER_ID> | current] <INTENT>  
  7.        am stopservice [--user <USER_ID> | current] <INTENT>  
  8.        am force-stop [--user <USER_ID> | all | current] <PACKAGE>  
  9.        am kill [--user <USER_ID> | all | current] <PACKAGE>  
  10.        am kill-all  
  11.        am broadcast [--user <USER_ID> | all | current] <INTENT>  
  12.        am instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]  
  13.                [--user <USER_ID> | current]  
  14.                [--no-window-animation] <COMPONENT>  
  15.        am profile start [--user <USER_ID> current] <PROCESS> <FILE>  
  16.        am profile stop [--user <USER_ID> current] [<PROCESS>]  
  17.        am dumpheap [--user <USER_ID> current] [-n] <PROCESS> <FILE>  
  18.        am set-debug-app [-w] [--persistent] <PACKAGE>  
  19.        am clear-debug-app  
  20.        am monitor [--gdb <port>]  
  21.        am hang [--allow-restart]  
  22.        am restart  
  23.        am idle-maintenance  
  24.        am screen-compat [on|off] <PACKAGE>  
  25.        am to-uri [INTENT]  
  26.        am to-intent-uri [INTENT]  
  27.        am switch-user <USER_ID>  
  28.        am stop-user <USER_ID>  
  29.        am stack create <TASK_ID> <RELATIVE_STACK_BOX_ID> <POSITION> <WEIGHT>  
  30.        am stack movetask <TASK_ID> <STACK_ID> [true|false]  
  31.        am stack resize <STACdK_ID> <WEIGHT>  
  32.        am stack boxes  
  33.        am stack box <STACK_BOX_ID>  
  34.   
  35. am start: start an Activity.  Options are:  
  36.     -D: enable debugging  
  37.     -W: wait for launch to complete  
  38.     --start-profiler <FILE>: start profiler and send results to <FILE>  
  39.     -P <FILE>: like above, but profiling stops when app goes idle  
  40.     -R: repeat the activity launch <COUNT> times.  Prior to each repeat,  
  41.         the top activity will be finished.  
  42.     -S: force stop the target app before starting the activity  
  43.     --opengl-trace: enable tracing of OpenGL functions  
  44.     --user <USER_ID> | current: Specify which user to run as; if not  
  45.         specified then run as the current user.  
  46.   
  47. am startservice: start a Service.  Options are:  
  48.     --user <USER_ID> | current: Specify which user to run as; if not  
  49.         specified then run as the current user.  
  50.   
  51. am stopservice: stop a Service.  Options are:  
  52.     --user <USER_ID> | current: Specify which user to run as; if not  
  53.         specified then run as the current user.  
  54.   
  55. am force-stop: force stop everything associated with <PACKAGE>.  
  56.     --user <USER_ID> | all | current: Specify user to force stop;  
  57.         all users if not specified.  
  58.   
  59. am kill: Kill all processes associated with <PACKAGE>.  Only kills.  
  60.   processes that are safe to kill -- that is, will not impact the user  
  61.   experience.  
  62.     --user <USER_ID> | all | current: Specify user whose processes to kill;  
  63.         all users if not specified.  
  64.   
  65. am kill-all: Kill all background processes.  
  66.   
  67. am broadcast: send a broadcast Intent.  Options are:  
  68.     --user <USER_ID> | all | current: Specify which user to send to; if not  
  69.         specified then send to all users.  
  70.     --receiver-permission <PERMISSION>: Require receiver to hold permission.  
  71.   
  72. am instrument: start an Instrumentation.  Typically this target <COMPONENT>  
  73.   is the form <TEST_PACKAGE>/<RUNNER_CLASS>.  Options are:  
  74.     -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT).  Use with  
  75.         [-e perf true] to generate raw output for performance measurements.  
  76.     -e <NAME> <VALUE>: set argument <NAME> to <VALUE>.  For test runners a  
  77.         common form is [-e <testrunner_flag> <value>[,<value>...]].  
  78.     -p <FILE>: write profiling data to <FILE>  
  79.     -w: wait for instrumentation to finish before returning.  Required for  
  80.         test runners.  
  81.     --user <USER_ID> | current: Specify user instrumentation runs in;  
  82.         current user if not specified.  
  83.     --no-window-animation: turn off window animations while running.  
  84.   
  85. am profile: start and stop profiler on a process.  The given <PROCESS> argument  
  86.   may be either a process name or pid.  Options are:  
  87.     --user <USER_ID> | current: When supplying a process name,  
  88.         specify user of process to profile; uses current user if not specified.  
  89.   
  90. am dumpheap: dump the heap of a process.  The given <PROCESS> argument may  
  91.   be either a process name or pid.  Options are:  
  92.     -n: dump native heap instead of managed heap  
  93.     --user <USER_ID> | current: When supplying a process name,  
  94.         specify user of process to dump; uses current user if not specified.  
  95.   
  96. am set-debug-app: set application <PACKAGE> to debug.  Options are:  
  97.     -w: wait for debugger when application starts  
  98.     --persistent: retain this value  
  99.   
  100. am clear-debug-app: clear the previously set-debug-app.  
  101.   
  102. am bug-report: request bug report generation; will launch UI  
  103.     when done to select where it should be delivered.  
  104.   
  105. am monitor: start monitoring for crashes or ANRs.  
  106.     --gdb: start gdbserv on the given port at crash/ANR  
  107.   
  108. am hang: hang the system.  
  109.     --allow-restart: allow watchdog to perform normal system restart  
  110.   
  111. am restart: restart the user-space system.  
  112.   
  113. am idle-maintenance: perform idle maintenance now.  
  114.   
  115. am screen-compat: control screen compatibility mode of <PACKAGE>.  
  116.   
  117. am to-uri: print the given Intent specification as a URI.  
  118.   
  119. am to-intent-uri: print the given Intent specification as an intent: URI.  
  120.   
  121. am switch-user: switch to put USER_ID in the foreground, starting  
  122.   execution of that user if it is currently stopped.  
  123.   
  124. am stop-user: stop execution of USER_ID, not allowing it to run any  
  125.   code until a later explicit switch to it.  
  126.   
  127. am stack create: create a new stack relative to an existing one.  
  128.    <TASK_ID>: the task to populate the new stack with. Must exist.  
  129.    <RELATIVE_STACK_BOX_ID>: existing stack box's id.  
  130.    <POSITION>: 0: before <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,  
  131.                1: after <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,  
  132.                2: to left of <RELATIVE_STACK_BOX_ID>,  
  133.                3: to right of <RELATIVE_STACK_BOX_ID>,               4: above <R  
  134. ELATIVE_STACK_BOX_ID>, 5: below <RELATIVE_STACK_BOX_ID>  
  135.    <WEIGHT>: float between 0.2 and 0.8 inclusive.  
  136.   
  137. am stack movetask: move <TASK_ID> from its current stack to the top (true) or  
  138. bottom (false) of <STACK_ID>.  
  139.   
  140. am stack resize: change <STACK_ID> relative size to new <WEIGHT>.  
  141.   
  142. am stack boxes: list the hierarchy of stack boxes and their contents.  
  143.   
  144. am stack box: list the hierarchy of stack boxes rooted at <STACK_BOX_ID>.  
  145.   
  146. <INTENT> specifications include these flags and arguments:  
  147.     [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]  
  148.     [-c <CATEGORY> [-c <CATEGORY>] ...]  
  149.     [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]  
  150.     [--esn <EXTRA_KEY> ...]  
  151.     [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]  
  152.     [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]  
  153.     [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]  
  154.     [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]  
  155.     [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]  
  156.     [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]  
  157.     [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]  
  158.     [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]  
  159.     [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]  
  160.     [-n <COMPONENT>] [-f <FLAGS>]  
  161.     [--grant-read-uri-permission] [--grant-write-uri-permission]  
  162.     [--debug-log-resolution] [--exclude-stopped-packages]  
  163.     [--include-stopped-packages]  
  164.     [--activity-brought-to-front] [--activity-clear-top]  
  165.     [--activity-clear-when-task-reset] [--activity-exclude-from-recents]  
  166.     [--activity-launched-from-history] [--activity-multiple-task]  
  167.     [--activity-no-animation] [--activity-no-history]  
  168.     [--activity-no-user-action] [--activity-previous-is-top]  
  169.     [--activity-reorder-to-front] [--activity-reset-task-if-needed]  
  170.     [--activity-single-top] [--activity-clear-task]  
  171.     [--activity-task-on-home]  
  172.     [--receiver-registered-only] [--receiver-replace-pending]  
  173.     [--selector]  
  174.     [<URI> | <PACKAGE> | <COMPONENT>]  
  1. start [options] intent启动 intent 指定的 Activity。
    选项:
    • -D:启用调试。
    • -W:等待启动完成。
    • ---start-profiler file:启动分析器并将结果发送到 file。
    • -P file:类似于 --start-profiler,但当应用进入空闲状态时分析停止。
    • -R count:重复 Activity 启动 count 次数。在每次重复前,将完成顶部 Activity。
    • -S:启动 Activity 前强行停止目标应用。
    • --opengl-trace:启用 OpenGL 函数的跟踪。
    • --user user_id | current:指定要作为哪个用户运行;如果未指定,则作为当前用户运行。
  2. startservice [options] intent启动 intent 指定的 Service。
    选项:
    • --user user_id | current:指定要作为哪个用户运行;如果未指定,则作为当前用户运行。
  3. force-stop package强行停止与 package(应用的包名称)关联的所有应用。
  4. kill [options] package终止与 package(应用的包名称)关联的所有进程。此命令仅终止可安全终止且不会影响用户体验的进程。
    选项:
    • --user user_id | all | current:指定将终止其进程的用户;如果未指定,则终止所有用户的进程。
  5. kill-all终止所有后台进程。
  6. broadcast [options] intent发出广播 intent。
    选项:
    • [--user user_id | all | current]:指定要发送到的用户;如果未指定,则发送到所有用户。
  7. instrument [options] component使用 Instrumentation 实例启动监控。通常,目标 component 是表单 test_package/runner_class
    选项:
    • -r:输出原始结果(否则对 report_key_streamresult 进行解码)。与 [-e perf true] 结合使用以生成性能测量的原始输出。
    • -e name value:将参数 name 设为 value。对于测试运行器,通用表单为 -e testrunner_flag value[,value...]
    • -p file:将分析数据写入 file
    • -w:先等待仪器完成,然后再返回。测试运行器需要使用此选项。
    • --no-window-animation:运行时关闭窗口动画。
    • --user user_id | current:指定仪器在哪个用户中运行;如果未指定,则在当前用户中运行。
  8. profile start process file启动 process 的分析器,将结果写入 file。
  9. profile stop process停止 process 的分析器。
  10. dumpheap [options] process file转储 process 的堆,写入 file
    选项:
    • --user [user_id|current]:提供进程名称时,指定要转储的进程用户;如果未指定,则使用当前用户。
    • -n:转储原生堆,而非托管堆。
  11. set-debug-app [options] package将应用 package 设为调试。
    选项:
    • -w:应用启动时等待调试程序。
    • --persistent:保留此值。
  12. clear-debug-app使用 set-debug-app 清除以前针对调试用途设置的软件包。
  13. monitor [options]启动对崩溃或 ANR 的监控。
    选项:
    • --gdb:在崩溃/ANR 时在给定端口上启动 gdbserv。
  14. screen-compat {on|off} package控制 package 的屏幕兼容性模式。
  15. display-size [reset|widthxheight]替换模拟器/设备显示尺寸。此命令对于在不同尺寸的屏幕上测试您的应用非常有用,它支持使用大屏设备模仿小屏幕分辨率(反之亦然)。
    示例:
    am display-size 1280x800
  16. display-density dpi替换模拟器/设备显示密度。此命令对于在不同密度的屏幕上测试您的应用非常有用,它支持使用低密度屏幕在高密度环境环境上进行测试(反之亦然)。
    示例:
    am display-density 480
  17. to-uri intent将给定的 intent 规范以 URI 的形式输出。
  18. to-intent-uri intent将给定的 intent 规范以 intent:URI 的形式输出。

当前文章价值1.39元,扫一扫支付后添加微信提供帮助!(如不能解决您的问题,可以申请退款)

你可能感兴趣的文章

来源:每日教程每日一例,深入学习实用技术教程,关注公众号TeachCourse
转载请注明出处: https://www.teachcourse.cn/07131629-adb-shell-am ,谢谢支持!

资源分享

生活杂谈之台式电脑如何实现无线上网-无线网卡 生活杂谈之台式电脑如何实现无线
ubuntu系统检查哪些工具或服务依赖Python3 ubuntu系统检查哪些工具或服务依
Android控件ListView熟悉divider详细介绍和示例说明 Android控件ListView熟悉divi
解决:启动Genymotion提示“Unable to load VirtualBox engine”的错误 解决:启动Genymotion提示“Un

发表评论

呲牙 憨笑 坏笑 偷笑 色 微笑 抓狂 睡觉 酷 流汗 鼓掌 大哭 可怜 疑问 晕 惊讶 得意 尴尬 发怒 奋斗 衰 骷髅 啤酒 吃饭 礼物 强 弱 握手 OK NO 勾引 拳头 差劲 爱你

表情