標籤:android style blog color 使用 資料 io for
adb shell am使用此命令可以從cmd控制台啟動 activity, services;發送 broadcast等等:
1 C:\Users\Administrator>adb shell am 2 usage: am [subcommand] [options] 3 4 start an Activity: am start [-D] [-W] <INTENT> 5 -D: enable debugging 6 -W: wait for launch to complete 7 8 start a Service: am startservice <INTENT> 9 10 send a broadcast Intent: am broadcast <INTENT>11 12 start an Instrumentation: am instrument [flags] <COMPONENT>13 -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)14 -e <NAME> <VALUE>: set argument <NAME> to <VALUE>15 -p <FILE>: write profiling data to <FILE>16 -w: wait for instrumentation to finish before returning17 18 start profiling: am profile <PROCESS> start <FILE>19 stop profiling: am profile <PROCESS> stop20 21 start monitoring: am monitor [--gdb <port>]22 --gdb: start gdbserv on the given port at crash/ANR23 24 <INTENT> specifications include these flags:25 [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]26 [-c <CATEGORY> [-c <CATEGORY>] ...]27 [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]28 [--esn <EXTRA_KEY> ...]29 [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]30 [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]31 [-n <COMPONENT>] [-f <FLAGS>]32 [--grant-read-uri-permission] [--grant-write-uri-permission]33 [--debug-log-resolution]34 [--activity-brought-to-front] [--activity-clear-top]35 [--activity-clear-when-task-reset] [--activity-exclude-from-recents]36 [--activity-launched-from-history] [--activity-multiple-task]37 [--activity-no-animation] [--activity-no-history]38 [--activity-no-user-action] [--activity-previous-is-top]39 [--activity-reorder-to-front] [--activity-reset-task-if-needed]40 [--activity-single-top]41 [--receiver-registered-only] [--receiver-replace-pending]42 [<URI>]
使用執行個體:如啟動一個 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