Builder


class Builder
kotlin.Any
   ↳ android.app.AutomaticZenRule.Builder

Summary

Public constructors

Builder(name: String, conditionId: Uri)

Public methods
AutomaticZenRule

AutomaticZenRule.Builder
setConditionId(conditionId: Uri)

Sets the representation of the state that causes this rule to become active.

AutomaticZenRule.Builder
setConfigurationActivity(configurationActivity: ComponentName?)

Sets the configuration activity - an activity that handles NotificationManager#ACTION_AUTOMATIC_ZEN_RULE that shows the user more information about this rule and/or allows them to configure it.

AutomaticZenRule.Builder

Sets the ZenDeviceEffects associated to this rule.

AutomaticZenRule.Builder
setEnabled(enabled: Boolean)

Enables this rule.

AutomaticZenRule.Builder
setIconResId(iconResId: Int)

Sets a resource id of a tintable vector drawable representing the rule in image form.

AutomaticZenRule.Builder
setInterruptionFilter(interruptionFilter: Int)

Sets the interruption filter that is applied when this rule is active.

AutomaticZenRule.Builder
setManualInvocationAllowed(allowManualInvocation: Boolean)

Sets whether this rule can be manually activated by the user even when the triggering condition for the rule is not met.

AutomaticZenRule.Builder
setName(name: String)

Sets the name of this rule.

AutomaticZenRule.Builder

Sets the component name of the android.service.notification.ConditionProviderService that manages this rule (but note that android.service.notification.ConditionProviderService is deprecated in favor of using NotificationManager#setAutomaticZenRuleState to notify the system about the state of your rule).

AutomaticZenRule.Builder

Sets a user visible description of when this rule will be active (see Condition#STATE_TRUE).

AutomaticZenRule.Builder
setType(type: Int)

Sets the type of the rule.

AutomaticZenRule.Builder

Sets the zen policy.

Public constructors

Builder

Builder(rule: AutomaticZenRule)
Parameters
rule AutomaticZenRule: This value cannot be null.

Builder

Builder(
    name: String,
    conditionId: Uri)
Parameters
name String: This value cannot be null.
conditionId Uri: This value cannot be null.

Public methods

build

fun build(): AutomaticZenRule
Return
AutomaticZenRule This value cannot be null.

setConditionId

fun setConditionId(conditionId: Uri): AutomaticZenRule.Builder

Sets the representation of the state that causes this rule to become active.

Parameters
conditionId Uri: This value cannot be null.
Return
AutomaticZenRule.Builder This value cannot be null.

setConfigurationActivity

fun setConfigurationActivity(configurationActivity: ComponentName?): AutomaticZenRule.Builder

Sets the configuration activity - an activity that handles NotificationManager#ACTION_AUTOMATIC_ZEN_RULE that shows the user more information about this rule and/or allows them to configure it. This is required to be non-null for rules that are not backed by a android.service.notification.ConditionProviderService.

This is exclusive with setOwner; rules where a configuration activity is set will not use the android.service.notification.ConditionProviderService supplied there to determine whether the rule should be active.

Parameters
configurationActivity ComponentName?: This value may be null.

setDeviceEffects

fun setDeviceEffects(deviceEffects: ZenDeviceEffects?): AutomaticZenRule.Builder

Sets the ZenDeviceEffects associated to this rule. Device effects specify changes to the device behavior that should apply while the rule is active, but are not directly related to suppressing notifications (for example: disabling always-on display).

When updating an existing rule via NotificationManager#updateAutomaticZenRule, a null value here means the previous set of effects is retained.

Parameters
deviceEffects ZenDeviceEffects?: This value may be null.

setEnabled

fun setEnabled(enabled: Boolean): AutomaticZenRule.Builder

Enables this rule. Rules are enabled by default.

Return
AutomaticZenRule.Builder This value cannot be null.

setIconResId

fun setIconResId(iconResId: Int): AutomaticZenRule.Builder

Sets a resource id of a tintable vector drawable representing the rule in image form.

Return
AutomaticZenRule.Builder This value cannot be null.

setManualInvocationAllowed

fun setManualInvocationAllowed(allowManualInvocation: Boolean): AutomaticZenRule.Builder

Sets whether this rule can be manually activated by the user even when the triggering condition for the rule is not met.

Return
AutomaticZenRule.Builder This value cannot be null.

setName

fun setName(name: String): AutomaticZenRule.Builder

Sets the name of this rule.

Parameters
name String: This value cannot be null.
Return
AutomaticZenRule.Builder This value cannot be null.

setOwner

fun setOwner(owner: ComponentName?): AutomaticZenRule.Builder

Sets the component name of the android.service.notification.ConditionProviderService that manages this rule (but note that android.service.notification.ConditionProviderService is deprecated in favor of using NotificationManager#setAutomaticZenRuleState to notify the system about the state of your rule).

This is exclusive with setConfigurationActivity; rules where a configuration activity is set will not use the component set here to determine whether the rule should be active.

Parameters
owner ComponentName?: This value may be null.
Return
AutomaticZenRule.Builder This value cannot be null.

setTriggerDescription

fun setTriggerDescription(description: String?): AutomaticZenRule.Builder

Sets a user visible description of when this rule will be active (see Condition#STATE_TRUE).

A description should be a (localized) string like "Mon-Fri, 9pm-7am" or "When connected to [Car Name]".

Parameters
description String?: This value may be null.
Return
AutomaticZenRule.Builder This value cannot be null.

setZenPolicy

fun setZenPolicy(policy: ZenPolicy?): AutomaticZenRule.Builder

Sets the zen policy.

When updating an existing rule via NotificationManager#updateAutomaticZenRule, a null value here means the previous policy is retained.

Parameters
policy ZenPolicy?: This value may be null.