adb shell am 的用法

來源:互聯網
上載者:User

標籤: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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.