【问题标题】:Android 8.0 and plus background service after app killed from recent [closed]Android 8.0 和应用程序最近被杀死后的后台服务 [关闭]
【发布时间】:2020-09-14 11:47:51
【问题描述】:

当用户收到新消息时,我正在开发聊天应用程序,他应该收到通知。它在 android 7.0 及更低版本中运行良好。但在 android 8.0 及更高版本中,应用程序从堆栈中清除后后台服务停止。有什么方法可以让服务保持活动状态以接收通知。

【问题讨论】:

    标签: java android firebase notifications


    【解决方案1】:

    您需要为 Oreo (Android 8.0) 及更高版本运行前台服务。 Android 将自动停止您的服务。 您需要了解服务。 https://developer.android.com/guide/components/services[1]

    【讨论】:

    • 谢谢。我想要没有前台服务的解决方案
    • 不,您不能在 Android 8.0 及更高版本上使用后台服务。您可以查看 JobScheduler 和 Work-manager 以获取有关后台服务的更多详细信息。也许你会找到更好的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-08
    • 2018-03-18
    • 2012-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多