2010年11月10日 星期三

[Tips] Run Android application from command line

syntax:
# am start -a android.intent.action.MAIN -n package/class_fullname

example:
# am start -a android.intent.action.MAIN -n my.demo/my.demo.HelloWorld

usage:
usage: am [subcommand] [options]

    start an Activity: am start [-D] [-W] 
        -D: enable debugging
        -W: wait for launch to complete

    start a Service: am startservice 

    send a broadcast Intent: am broadcast 

    start an Instrumentation: am instrument [flags] 
        -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
        -e  : set argument  to 
        -p : write profiling data to 
        -w: wait for instrumentation to finish before returning

    start profiling: am profile  start 
    stop profiling: am profile  stop

     specifications include these flags:
        [-a ] [-d ] [-t ]
        [-c  [-c ] ...]
        [-e|--es   ...]
        [--esn  ...]
        [--ez   ...]
        [-e|--ei   ...]
        [-n ] [-f ]
        [--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]
        []

reference: Run Android Application from Command Line

沒有留言: