How to start and stop android service from a adb shell?

前端 未结 11 1062
别跟我提以往
别跟我提以往 2020-12-07 16:32

I need to write a shell script to start and stop an android service .

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 17:14

    If you want to run the script in adb shell, then I am trying to do the same, but with an application. I think you can use "am start" command

    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
    
    start monitoring: am monitor [--gdb ]
        --gdb: start gdbserv on the given port at crash/ANR
    
     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]
        []
    

提交回复
热议问题