英文:
Android 8.0 and plus background service after app killed from recent
问题
我正在开发聊天应用,当用户收到新消息时,他应该收到通知。在 Android 7.0 及更低版本中,这个功能运行良好。但是在 Android 8.0 及更高版本中,当应用从堆栈中清除后,后台服务会停止。是否有办法让服务保持活动状态以接收通知。
英文:
I am developing the chat app when user receive new message he should receive a notification. it is working well in android 7.0 and less. But in android 8.0 and above background service stop after app clear from stack. Is there any way to keep service alive to receive notification.
答案1
得分: 1
你需要在 Oreo(Android 8.0)及更高版本上运行前台服务。Android 会自动停止你的服务。
你需要了解有关服务的知识。
https://developer.android.com/guide/components/services[1]
英文:
You need to run foreground service for Oreo (Android 8.0) and higher. Android will stop your service automatically.
You need to learn about services.
https://developer.android.com/guide/components/services[1]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论