【问题标题】:Android - Kill Bound Activity on Service DestroyAndroid - 在服务销毁时终止绑定活动
【发布时间】:2014-05-05 18:26:38
【问题描述】:

我有一个活动:

@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 service process


    【解决方案1】:

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

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

    【讨论】:

    • 你指的是Service的onStop还是onPause方法?或活动?因为我需要该服务在 Android 任务管理器中杀死活动时将其杀死。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多