命令行执行Android程序
一直以来都是用adb install xxx.apk来安装Android的package,然后在模拟器的menu screen上点击执行程序,今天需要在命令行中执行Android程序,查了半天,终于找到了相应的指令:
首先我们看看am指令介绍吧:
- # am
- usage: am [subcommand] [options]
- start an Activity: am start [-D] [-W] <INTENT>
- -D: enable debugging
- -W: wait for launch to complete
- start a Service: am startservice <INTENT>
- send a broadcast Intent: am broadcast <INTENT>
- start an Instrumentation: am instrument [flags] <COMPONENT>
- -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
- -e <NAME> <VALUE>: set argument <NAME> to <VALUE>
- -p <FILE>: write profiling data to <FILE>
- -w: wait for instrumentation to finish before returning
- start profiling: am profile <PROCESS> start <FILE>
- stop profiling: am profile <PROCESS> stop
- <INTENT> specifications include these flags:
- [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
- [-c <CATEGORY> [-c <CATEGORY>] ...]
- [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
- [--esn <EXTRA_KEY> ...]
- [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
- [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
- [-n <COMPONENT>] [-f <FLAGS>]
- [--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]
- [<URI>]
从上可知:
am start 用来启动一个activity
am startservice 用来启动一个service,比如我们要
am broadcast 用来发送一个广播
当我们要运行camera程序时,可以用以下命令:
# am start -n com.android.camera/com.android.camera.Camera
相关推荐
吹云 2020-11-05
84407805 2020-11-01
曾是土木人 2020-10-31
87201442 2020-10-15
java0 2020-09-29
81437716 2020-09-18
81437716 2020-09-13
bluecarrot 2020-09-11
myCat 2020-09-09
83427718 2020-09-07
85560694 2020-09-03
89520991 2020-08-21
89550191 2020-08-09
katie000 2020-08-04
hunningtu 2020-07-30
89961330 2020-07-28
yuzhongdelei0 2020-07-28
yuzhongdelei0 2020-07-27