Android 8.0及更高版本中,应用在被从最近任务中关闭后的后台服务。

huangapple go评论58阅读模式
英文:

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]

huangapple
  • 本文由 发表于 2020年9月14日 19:47:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63883674.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定