退出应用程序后服务停止

发布于 2024-10-06 22:34:10 字数 148 浏览 0 评论 0原文

我正在开发一个音乐播放器应用程序,它作为远程服务运行。当我按返回按钮退出时,服务停止。为什么会发生这种情况?

它还显示以下 logcat 消息

android.app.ServiceConnectionLeaked

I am working on a music player app and it runs as a remote service. When I press back button to exit, the service stops. Why is this happening?

It also shows the following logcat message

android.app.ServiceConnectionLeaked

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别把无礼当个性 2024-10-13 22:34:10

您需要从服务的 onStartCommand 返回 START_STICKY。查看官方 文档

You need to return START_STICKY from the service's onStartCommand. Check the official documentation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文