服务销毁上的Android-Kill绑定活动

服务销毁上的Android-Kill绑定活动,android,service,process,Android,Service,Process,我有一项活动: @Override protected void onStart() { super.onStart(); // Bind to LocalService exampleService = new Intent(this, exampleService.class); bindService(exampleService, mConnection, Context.BIND_AUTO_CREATE); startService(exampl

我有一项活动:

@Override
protected void onStart() {
    super.onStart();
    // Bind to LocalService
    exampleService = new Intent(this, exampleService.class);
    bindService(exampleService, mConnection, Context.BIND_AUTO_CREATE);
    startService(exampleService);
}
现在,如果我去管理应用程序,检查正在运行的服务并终止该服务,那么该活动仍然作为后台进程运行


如何使绑定到服务的活动在销毁时也被终止?

这是因为在android中,启动服务时,需要在终止绑定的任何活动之前手动停止该服务。因此,尝试在onStop或Onpause方法中停止该服务

访问此
我们已经启动了一个新论坛,您可以在其中询问有关android的问题并回答问题。

您指的是该服务的onStop或onPause方法吗?还是活动?因为我需要服务在Android任务管理器中终止活动时终止活动。