Using activity manager (am) 使用方法
来源:互联网 发布:娄底网络电视台 编辑:程序博客网 时间:2024/05/16 17:43
Using activity manager (am)
Within an adb shell, you can issue commands with the activity manager (am
) tool to perform various system actions, such as start an activity, force-stop a process, broadcast an intent, modify the device screen properties, and more. While in a shell, the syntax is:
am <command>
You can also issue an activity manager command directly from adb without entering a remote shell. For example:
adb shell am start -a android.intent.action.VIEW
start [options] <INTENT>
Start an Activity
specified by<INTENT>
.See the Specification for <INTENT> arguments.
Options are:
-D
: Enable debugging.-W
: Wait for launch to complete.--start-profiler <FILE>
: Start profiler and send results to<FILE>
.-P <FILE>
: Like--start-profiler
, but profiling stops when the app goes idle.-R
: Repeat the activity launch<COUNT>
times. Prior to each repeat, the top activity will be finished.-S
: Force stop the target app before starting the activity.--opengl-trace
: Enable tracing of OpenGL functions.--user <USER_ID> | current
: Specify which user to run as; if not specified, then run as the current user.
startservice [options] <INTENT>
Start the Service
specified by<INTENT>
.See the Specification for <INTENT> arguments.
Options are:
--user <USER_ID> | current
: Specify which user to run as; if not specified, then run as the current user.
force-stop <PACKAGE>
Force stop everything associated with <PACKAGE>
(the app's package name).kill [options] <PACKAGE>
Kill all processes associated with <PACKAGE>
(the app's package name). This command kills only processes that are safe to kill and that will not impact the user experience.Options are:
--user <USER_ID> | all | current
: Specify user whose processes to kill; all users if not specified.
kill-all
Kill all background processes.broadcast [options] <INTENT>
Issue a broadcast intent.See the Specification for <INTENT> arguments.
Options are:
[--user <USER_ID> | all | current]
: Specify which user to send to; if not specified then send to all users.
instrument [options] <COMPONENT>
Start monitoring with an Instrumentation
instance. Typically the target<COMPONENT>
is the form<TEST_PACKAGE>/<RUNNER_CLASS>
.Options are:
-r
: Print raw results (otherwise decode<REPORT_KEY_STREAMRESULT>
). Use with[-e perf true]
to generate raw output for performance measurements.-e <NAME> <VALUE>
: Set argument<NAME>
to<VALUE>
. For test runners a common form is-e <testrunner_flag> <value>[,<value>...]
.-p <FILE>
: Write profiling data to<FILE>
.-w
: Wait for instrumentation to finish before returning. Required for test runners.--no-window-animation
: Turn off window animations while running.--user <USER_ID> | current
: Specify which user instrumentation runs in; current user if not specified.
profile start <PROCESS> <FILE>
Start profiler on <PROCESS>
, write results to <FILE>
.profile stop <PROCESS>
Stop profiler on <PROCESS>
.dumpheap [options] <PROCESS> <FILE>
Dump the heap of <PROCESS>
, write to <FILE>
.Options are:
--user [<USER_ID>|current]
: When supplying a process name, specify user of process to dump; uses current user if not specified.-n
: Dump native heap instead of managed heap.
set-debug-app [options] <PACKAGE>
Set application <PACKAGE>
to debug.Options are:
-w
: Wait for debugger when application starts.--persistent
: Retain this value.
clear-debug-app
Clear the package previous set for debugging with set-debug-app
.monitor [options]
Start monitoring for crashes or ANRs.Options are:
--gdb
: Start gdbserv on the given port at crash/ANR.
screen-compat [on|off] <PACKAGE>
Control screen compatibility mode of <PACKAGE>
.display-size [reset|<WxH>]
Override emulator/device display size. This command is helpful for testing your app across different screen sizes by mimicking a small screen resolution using a device with a large screen, and vice versa.Example:am display-size 1280x800
display-density <dpi>
Override emulator/device display density. This command is helpful for testing your app across different screen densities on high-density screen environment using a low density screen, and vice versa.Example:am display-density 480
to-uri <INTENT>
Print the given intent specification as a URI.See the Specification for <INTENT> arguments.
to-intent-uri <INTENT>
Print the given intent specification as an intent:
URI.See the Specification for <INTENT> arguments.
Specification for <INTENT> arguments
For activity manager commands that take a <INTENT>
argument, you can specify the intent with the following options:
-a <ACTION>
- Specify the intent action, such as "android.intent.action.VIEW". You can declare this only once.
-d <DATA_URI>
- Specify the intent data URI, such as "content://contacts/people/1". You can declare this only once.
-t <MIME_TYPE>
- Specify the intent MIME type, such as "image/png". You can declare this only once.
-c <CATEGORY>
- Specify an intent category, such as "android.intent.category.APP_CONTACTS".
-n <COMPONENT>
- Specify the component name with package name prefix to create an explicit intent, such as "com.example.app/.ExampleActivity".
-f <FLAGS>
- Add flags to the intent, as supported by
setFlags()
. --esn <EXTRA_KEY>
- Add a null extra. This option is not supported for URI intents.
-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
- Add string data as a key-value pair.
--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>
- Add boolean data as a key-value pair.
--ei <EXTRA_KEY> <EXTRA_INT_VALUE>
- Add integer data as a key-value pair.
--el <EXTRA_KEY> <EXTRA_LONG_VALUE>
- Add long data as a key-value pair.
--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE>
- Add float data as a key-value pair.
--eu <EXTRA_KEY> <EXTRA_URI_VALUE>
- Add URI data as a key-value pair.
--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>
- Add a component name, which is converted and passed as a
ComponentName
object. --eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]
- Add an array of integers.
--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]
- Add an array of longs.
--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]
- Add an array of floats.
--grant-read-uri-permission
- Include the flag
FLAG_GRANT_READ_URI_PERMISSION
. --grant-write-uri-permission
- Include the flag
FLAG_GRANT_WRITE_URI_PERMISSION
. --debug-log-resolution
- Include the flag
FLAG_DEBUG_LOG_RESOLUTION
. --exclude-stopped-packages
- Include the flag
FLAG_EXCLUDE_STOPPED_PACKAGES
. --include-stopped-packages
- Include the flag
FLAG_INCLUDE_STOPPED_PACKAGES
. --activity-brought-to-front
- Include the flag
FLAG_ACTIVITY_BROUGHT_TO_FRONT
. --activity-clear-top
- Include the flag
FLAG_ACTIVITY_CLEAR_TOP
. --activity-clear-when-task-reset
- Include the flag
FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
. --activity-exclude-from-recents
- Include the flag
FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
. --activity-launched-from-history
- Include the flag
FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
. --activity-multiple-task
- Include the flag
FLAG_ACTIVITY_MULTIPLE_TASK
. --activity-no-animation
- Include the flag
FLAG_ACTIVITY_NO_ANIMATION
. --activity-no-history
- Include the flag
FLAG_ACTIVITY_NO_HISTORY
. --activity-no-user-action
- Include the flag
FLAG_ACTIVITY_NO_USER_ACTION
. --activity-previous-is-top
- Include the flag
FLAG_ACTIVITY_PREVIOUS_IS_TOP
. --activity-reorder-to-front
- Include the flag
FLAG_ACTIVITY_REORDER_TO_FRONT
. --activity-reset-task-if-needed
- Include the flag
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
. --activity-single-top
- Include the flag
FLAG_ACTIVITY_SINGLE_TOP
. --activity-clear-task
- Include the flag
FLAG_ACTIVITY_CLEAR_TASK
. --activity-task-on-home
- Include the flag
FLAG_ACTIVITY_TASK_ON_HOME
. --receiver-registered-only
- Include the flag
FLAG_RECEIVER_REGISTERED_ONLY
. --receiver-replace-pending
- Include the flag
FLAG_RECEIVER_REPLACE_PENDING
. --selector
- Requires the use of
-d
and -t
options to set the intent data and type. <URI> <COMPONENT> <PACKAGE>
- You can directly specify a URI, package name, and component name when not qualified by one of the above options. When an argument is unqualified, the tool assumes the argument is a URI if it contains a ":" (colon); it assumes the argument is a component name if it contains a "/" (forward-slash); otherwise it assumes the argument is a package name.
For activity manager commands that take a <INTENT>
argument, you can specify the intent with the following options:
-a <ACTION>
- Specify the intent action, such as "android.intent.action.VIEW". You can declare this only once.
-d <DATA_URI>
- Specify the intent data URI, such as "content://contacts/people/1". You can declare this only once.
-t <MIME_TYPE>
- Specify the intent MIME type, such as "image/png". You can declare this only once.
-c <CATEGORY>
- Specify an intent category, such as "android.intent.category.APP_CONTACTS".
-n <COMPONENT>
- Specify the component name with package name prefix to create an explicit intent, such as "com.example.app/.ExampleActivity".
-f <FLAGS>
- Add flags to the intent, as supported by
setFlags()
. --esn <EXTRA_KEY>
- Add a null extra. This option is not supported for URI intents.
-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE>
- Add string data as a key-value pair.
--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>
- Add boolean data as a key-value pair.
--ei <EXTRA_KEY> <EXTRA_INT_VALUE>
- Add integer data as a key-value pair.
--el <EXTRA_KEY> <EXTRA_LONG_VALUE>
- Add long data as a key-value pair.
--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE>
- Add float data as a key-value pair.
--eu <EXTRA_KEY> <EXTRA_URI_VALUE>
- Add URI data as a key-value pair.
--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>
- Add a component name, which is converted and passed as a
ComponentName
object. --eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]
- Add an array of integers.
--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]
- Add an array of longs.
--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]
- Add an array of floats.
--grant-read-uri-permission
- Include the flag
FLAG_GRANT_READ_URI_PERMISSION
. --grant-write-uri-permission
- Include the flag
FLAG_GRANT_WRITE_URI_PERMISSION
. --debug-log-resolution
- Include the flag
FLAG_DEBUG_LOG_RESOLUTION
. --exclude-stopped-packages
- Include the flag
FLAG_EXCLUDE_STOPPED_PACKAGES
. --include-stopped-packages
- Include the flag
FLAG_INCLUDE_STOPPED_PACKAGES
. --activity-brought-to-front
- Include the flag
FLAG_ACTIVITY_BROUGHT_TO_FRONT
. --activity-clear-top
- Include the flag
FLAG_ACTIVITY_CLEAR_TOP
. --activity-clear-when-task-reset
- Include the flag
FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
. --activity-exclude-from-recents
- Include the flag
FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
. --activity-launched-from-history
- Include the flag
FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
. --activity-multiple-task
- Include the flag
FLAG_ACTIVITY_MULTIPLE_TASK
. --activity-no-animation
- Include the flag
FLAG_ACTIVITY_NO_ANIMATION
. --activity-no-history
- Include the flag
FLAG_ACTIVITY_NO_HISTORY
. --activity-no-user-action
- Include the flag
FLAG_ACTIVITY_NO_USER_ACTION
. --activity-previous-is-top
- Include the flag
FLAG_ACTIVITY_PREVIOUS_IS_TOP
. --activity-reorder-to-front
- Include the flag
FLAG_ACTIVITY_REORDER_TO_FRONT
. --activity-reset-task-if-needed
- Include the flag
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
. --activity-single-top
- Include the flag
FLAG_ACTIVITY_SINGLE_TOP
. --activity-clear-task
- Include the flag
FLAG_ACTIVITY_CLEAR_TASK
. --activity-task-on-home
- Include the flag
FLAG_ACTIVITY_TASK_ON_HOME
. --receiver-registered-only
- Include the flag
FLAG_RECEIVER_REGISTERED_ONLY
. --receiver-replace-pending
- Include the flag
FLAG_RECEIVER_REPLACE_PENDING
. --selector
- Requires the use of
-d
and-t
options to set the intent data and type. <URI> <COMPONENT> <PACKAGE>
- You can directly specify a URI, package name, and component name when not qualified by one of the above options. When an argument is unqualified, the tool assumes the argument is a URI if it contains a ":" (colon); it assumes the argument is a component name if it contains a "/" (forward-slash); otherwise it assumes the argument is a package name.
- Using activity manager (am) 使用方法
- What I am using
- activity manager
- am命令 启动activity
- Oracle using resource manager
- openfire connection manager using
- Using the Location Manager
- Using the ToolTip Manager
- Android Using Location Manager
- android am start的使用方法
- 利用am start 打开activity
- Wince Cab Manager使用方法
- Wince Cab Manager使用方法
- Wince Cab Manager使用方法
- Activity Manager框架解析
- Activity Manager框架解析
- Activity Manager Service总结
- Using the Hydra Process Manager
- Java性能优化权威指南
- 头文件那些事儿
- 什么是存储过程?
- 华为校园招聘上机试题 Java实现(一)
- jsp关于过滤器filter的使用。
- Using activity manager (am) 使用方法
- Ogre材质解析代码初步分析(一)
- WinCE注册表操作API
- SSH免密码登录失败
- 溜冰场的造价
- 重温数据结构-线性表的顺序表示与实现
- java23种设计模式--外观模式(facade)
- UFLDL 教程学习笔记(三)自编码与稀疏性
- 作业一