首页 文章

后台服务Android oreo(限制)

提问于
浏览
-1

如何使用Android Oreo处理后台服务?

我创建了intentservices和服务背景,但由于android Oreo限制,服务在应用程序关闭时停止

WhatsApp应用程序在Android 8.1 how is this possible 的后台工作?

检查此图片:

此外,应用程序关闭时广播接收器无法正常工作

1 回答

  • 0

    Android documentation中描述了Android后台服务 . 谷歌试图限制应用程序必须在后台运行服务的安全性和节省电池的自由 .

    您基本上有以下选择:

    1. Foreground Service 前台服务执行一些对用户来说很明显的操作 . 例如,音频应用程序将使用前台服务来播放音轨 .

    2. Background Service 后台服务在前台执行不是't directly noticed by the user. For example, if an app used a service to compact its storage, that would usually be a background service. If your app targets API level 26 or higher, the system imposes restrictions on running background services when the app itself isn't的操作 . 在大多数情况下,您的应用应该使用预定作业 .

    3. Bound Service 当应用程序组件通过调用bindService()绑定到服务时绑定服务 . 绑定服务提供客户端 - 服务器接口,允许组件与服务交互,发送请求,接收结果,甚至跨进程间通信(IPC)进行交互 . 只要绑定了另一个应用程序组件,绑定服务就会运行 .

相关问题