语言

Notification.Builder.SetForegroundServiceBehavior(Int32) 方法

定义

为与前台服务关联的通知指定所需的可见性策略。

[Android.Runtime.Register("setForegroundServiceBehavior", "(I)Landroid/app/Notification$Builder;", "GetSetForegroundServiceBehavior_IHandler", ApiSince=31)]
public virtual Android.App.Notification.Builder SetForegroundServiceBehavior(int behavior);
[<Android.Runtime.Register("setForegroundServiceBehavior", "(I)Landroid/app/Notification$Builder;", "GetSetForegroundServiceBehavior_IHandler", ApiSince=31)>]
abstract member SetForegroundServiceBehavior : int -> Android.App.Notification.Builder
override this.SetForegroundServiceBehavior : int -> Android.App.Notification.Builder

参数

behavior
Int32

int:FOREGROUND_SERVICE_DEFAULT、FOREGROUND_SERVICE_IMMEDIATE或FOREGROUND_SERVICE_DEFERRED值之一是下列值之一:Notification.FOREGROUND_SERVICE_DEFAULT Notification.FOREGROUND_SERVICE_IMMEDIATE Notification.FOREGROUND_SERVICE_DEFERRED

返回

此 Android.App.Notification.Builder 实例允许链接调用。

特性

注解

为与前台服务关联的通知指定所需的可见性策略。 默认情况下,系统可以选择在服务启动后将通知的可见性推迟一小段时间。 将FOREGROUND_SERVICE_IMMEDIATE传递给此方法,以确保不会延迟可见性。 传递FOREGROUND_SERVICE_DEFERRED以请求尽可能延迟可见性。 请注意,无法保证延迟的可见性。 在某些情况下,即使应用已使用此方法显式请求延迟显示,系统也会立即显示前台服务的关联通知。

Android 参考。android.app.Notification.Builder.setForegroundServiceBehavior

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于