am startservice com.xxx/.service.XXXService
i can start a service through the command above , but the am manual doesn't say anything about stop service.
how can i do that?
adb shell
ps | grep -i com.example.service
run-as com.example.service
kill -9 pId
exit
if your service work in the same process as your app. tested on android 5.1
If you intend to stop a service you developed yourself you can add a second service to your app that is only responsible to stop the other service.
Its onCreate() method only contains three lines of code:
public void onCreate() {
super.onCreate();
stopService(new Intent("<ActionIDofServiceToBeStopped>"));
stopSelf();
}
This way you can stop your service by just starting the second one via adb:
am startservice '<IDofStopperService>'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.