简体   繁体   English

具有通知频道的Android 8前台服务

[英]Android 8 Foreground Service with Notification Channel

I want to start a foreground service in Android 8 and I want to know how are foreground services compatible with the notification channel system. 我想在Android 8中启动前台服务,我想知道前台服务如何与通知通道系统兼容。

Let's say we start a foreground service, then we immediately create the required notification and assign it to a notification channel. 假设我们启动前台服务,然后立即创建所需的通知并将其分配给通知通道。 Suddenly, the user decides to go into System Settings and disable the notification channel. 突然,用户决定进入系统设置并禁用通知通道。

What happens in this case? 在这种情况下会发生什么? Will the service become a background service? 该服务会成为后台服务吗? Does it get killed? 它会被杀死吗? I haven't found a documented answer. 我没有找到有记录的答案。

Default notification settings: 默认通知设置:

在此输入图像描述

Foreground service notification: 前台服务通知: 在此输入图像描述

Disable notifications: 禁用通知:

在此输入图像描述

Android 8 shows this notification after few seconds (when you send your application to background): Android 8会在几秒钟后(当您将应用程序发送到后台时)显示此通知:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM