退出应用程序后服务停止
我正在开发一个音乐播放器应用程序,它作为远程服务运行。当我按返回按钮退出时,服务停止。为什么会发生这种情况?
它还显示以下 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从服务的
onStartCommand
返回START_STICKY
。查看官方 文档You need to return
START_STICKY
from the service'sonStartCommand
. Check the official documentation