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

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

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

11条回答
  •  感动是毒
    2020-12-07 17:10

    You need to add android:exported="true" to start service from ADB command line. Then your manifest looks something like this:

    
    
        
            
            
            
        
     
    

    And then from ADB

    To start service:

    adb shell am startservice com.your.package.name/.YourServiceName

    To stop service (on Marshmallow):

    adb shell am stopservice com.your.package.name/.YourServiceName

    To stop service (on Jelly Bean):

    adb shell am force-stop com.your.package.name

提交回复
热议问题