Android - 服务销毁时杀死绑定活动

时间:2014-05-05 09:52:08

标签: 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(exampleService);
}

现在如果我去管理应用程序并检查运行服务并终止服务,该活动仍然作为后台进程运行。

我怎样才能拥有它,以便绑定到服务的活动也会在destroy上被杀死?

1 个答案:

答案 0 :(得分:0)

这种情况正在发生,因为在Android中启动服务时,您需要在杀死绑定任何活动之前手动停止该服务。因此,请尝试在onStop()Onpause()方法中停止该服务。

访问此http://androidtutorial4u.blogspot.in/p/forum.html 我们已经开始了新的论坛,您可以在其中提出有关Android的问题以及回答问题。

相关问题