如何从adb停止android服务

如何从adb停止android服务,android,adb,Android,Adb,我可以通过上面的命令启动服务,但am手册中没有任何关于停止服务的内容 我该怎么做?如果您打算停止自己开发的服务,您可以向应用程序添加第二个服务,该服务只负责停止其他服务 其onCreate()方法只包含三行代码: am startservice com.xxx/.service.XXXService public void onCreate(){ super.onCreate(); 停止服务(新意图(“”); stopSelf(); } 这样,您只需通过adb启动第二个服务即可停止服务: p

我可以通过上面的命令启动服务,但am手册中没有任何关于停止服务的内容


我该怎么做?

如果您打算停止自己开发的服务,您可以向应用程序添加第二个服务,该服务只负责停止其他服务

其onCreate()方法只包含三行代码:

am startservice com.xxx/.service.XXXService
public void onCreate(){
super.onCreate();
停止服务(新意图(“”);
stopSelf();
}
这样,您只需通过adb启动第二个服务即可停止服务:

public void onCreate() {
  super.onCreate();
  stopService(new Intent("<ActionIDofServiceToBeStopped>"));
  stopSelf();
}
am startservice''
adb外壳
ps | grep-i com.example.service
作为com.example.service运行
杀死-9 pId
出口
如果您的服务与您的应用程序在同一流程中工作。 在安卓5.1上测试

am startservice '<IDofStopperService>'