Added in API level 24

AutomaticZenRule


class AutomaticZenRule : Parcelable
kotlin.Any
   ↳ android.app.AutomaticZenRule

Rule instance information for a zen (aka DND or Attention Management) mode.

Summary

Nested classes

Constants
static Int

The type for rules triggered by bedtime/sleeping, like time of day, or snore detection.

static Int

The type for rules triggered by driving detection, like Bluetooth connections or vehicle sounds.

static Int

The type for rules triggered by the user entering an immersive activity, like opening an app using WindowInsetsController.hide(int).

static Int

The type for rules created and managed by a device owner.

static Int

Rule is of a known type, but not one of the specific types.

static Int

The type for rules triggered by calendar events.

static Int

The type for rules triggered according to a time-based schedule.

static Int

The type for rules that have a ZenPolicy that implies that the device should not make sound and potentially hide some visual effects; may be triggered when entering a location where silence is requested, like a theater.

static Int

Rule is of an unknown type.

Inherited constants
Public constructors

AutomaticZenRule(name: String, owner: ComponentName?, configurationActivity: ComponentName?, conditionId: Uri, policy: ZenPolicy?, interruptionFilter: Int, enabled: Boolean)

Creates an automatic zen rule.

AutomaticZenRule(name: String!, owner: ComponentName!, conditionId: Uri!, interruptionFilter: Int, enabled: Boolean)

Creates an automatic zen rule.

Public methods
Int

Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

Uri!

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

ComponentName?

Returns the ComponentName of the activity that shows configuration options for this rule.

Long

Returns the time this rule was created, represented as milliseconds since the epoch.

ZenDeviceEffects?

Gets the ZenDeviceEffects of this rule.

Int

Gets the resource id of the drawable icon for this rule.

Int

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

String!

Returns the name of this rule.

ComponentName!

Returns the ComponentName of the condition provider service that owns this rule.

String?

Gets the user visible description of when this rule is active (see Condition.STATE_TRUE).

Int

Gets the type of the rule.

ZenPolicy?

Gets the ZenPolicy applied if getInterruptionFilter() is NotificationManager.INTERRUPTION_FILTER_PRIORITY.

Int

Boolean

Returns whether this rule is enabled.

Boolean

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

Unit
setConditionId(conditionId: Uri!)

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

Unit

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.

Unit

Sets the ZenDeviceEffects associated to this rule.

Unit
setEnabled(enabled: Boolean)

Enables this rule.

Unit
setInterruptionFilter(interruptionFilter: Int)

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

Unit
setName(name: String!)

Sets the name of this rule.

Unit
setZenPolicy(zenPolicy: ZenPolicy?)

Sets the ZenPolicy applied if getInterruptionFilter() is NotificationManager.INTERRUPTION_FILTER_PRIORITY.

String

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<AutomaticZenRule!>

Constants

TYPE_BEDTIME

Added in API level 35
static val TYPE_BEDTIME: Int

The type for rules triggered by bedtime/sleeping, like time of day, or snore detection.

Only the 'Wellbeing' app may own rules of this type.

Value: 3

TYPE_DRIVING

Added in API level 35
static val TYPE_DRIVING: Int

The type for rules triggered by driving detection, like Bluetooth connections or vehicle sounds.

Value: 4

TYPE_IMMERSIVE

Added in API level 35
static val TYPE_IMMERSIVE: Int

The type for rules triggered by the user entering an immersive activity, like opening an app using WindowInsetsController.hide(int).

Value: 5

TYPE_MANAGED

Added in API level 35
static val TYPE_MANAGED: Int

The type for rules created and managed by a device owner. These rules may not be fully editable by the device user.

Only a 'Device Owner' app may own rules of this type.

Value: 7

TYPE_OTHER

Added in API level 35
static val TYPE_OTHER: Int

Rule is of a known type, but not one of the specific types.

Value: 0

TYPE_SCHEDULE_CALENDAR

Added in API level 35
static val TYPE_SCHEDULE_CALENDAR: Int

The type for rules triggered by calendar events.

Value: 2

TYPE_SCHEDULE_TIME

Added in API level 35
static val TYPE_SCHEDULE_TIME: Int

The type for rules triggered according to a time-based schedule.

Value: 1

TYPE_THEATER

Added in API level 35
static val TYPE_THEATER: Int

The type for rules that have a ZenPolicy that implies that the device should not make sound and potentially hide some visual effects; may be triggered when entering a location where silence is requested, like a theater.

Value: 6

TYPE_UNKNOWN

Added in API level 35
static val TYPE_UNKNOWN: Int

Rule is of an unknown type. This is the default value if not provided by the owning app, and the value returned if the true type was added in an API level higher than the calling app's targetSdk.

Value: -1

Public constructors

AutomaticZenRule

Added in API level 24
AutomaticZenRule(source: Parcel!)

AutomaticZenRule

Added in API level 29
AutomaticZenRule(
    name: String,
    owner: ComponentName?,
    configurationActivity: ComponentName?,
    conditionId: Uri,
    policy: ZenPolicy?,
    interruptionFilter: Int,
    enabled: Boolean)

Creates an automatic zen rule.

Note: Prefer AutomaticZenRule.Builder to construct an AutomaticZenRule.

Parameters
name String: The name of the rule. This value cannot be null.
owner ComponentName?: The Condition Provider service that owns this rule. This can be null if you're using NotificationManager.setAutomaticZenRuleState(String, Condition) instead of android.service.notification.ConditionProviderService.
configurationActivity ComponentName?: 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 if you are not using a android.service.notification.ConditionProviderService. If you are, it overrides the information specified in your manifest. This value may be null.
conditionId Uri: A representation of the state that should cause your app to apply the given interruption filter. This value cannot be null.
interruptionFilter Int: The interruption filter defines which notifications are allowed to interrupt the user (e.g. via sound & vibration) while this rule is active.
policy ZenPolicy?: The policy defines which notifications are allowed to interrupt the user while this rule is active. This overrides the global policy while this rule is action (Condition.STATE_TRUE). This value may be null.
enabled Boolean: Whether the rule is enabled.

AutomaticZenRule

Added in API level 24
AutomaticZenRule(
    name: String!,
    owner: ComponentName!,
    conditionId: Uri!,
    interruptionFilter: Int,
    enabled: Boolean)

Deprecated: Use AutomaticZenRule.Builder to construct an AutomaticZenRule.

Creates an automatic zen rule.

Parameters
name String!: The name of the rule.
owner ComponentName!: The Condition Provider service that owns this rule.
interruptionFilter Int: The interruption filter defines which notifications are allowed to interrupt the user (e.g. via sound & vibration) while this rule is active.
enabled Boolean: Whether the rule is enabled.

Public methods

describeContents

Added in API level 24
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 24
fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj the reference object with which to compare.
o This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getConditionId

Added in API level 24
fun getConditionId(): Uri!

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

getConfigurationActivity

Added in API level 29
fun getConfigurationActivity(): ComponentName?

Returns the ComponentName of the activity that shows configuration options for this rule.

Return
ComponentName? This value may be null.

getCreationTime

Added in API level 24
fun getCreationTime(): Long

Returns the time this rule was created, represented as milliseconds since the epoch.

getDeviceEffects

Added in API level 35
fun getDeviceEffects(): ZenDeviceEffects?

Gets the ZenDeviceEffects of this rule.

Return
ZenDeviceEffects? This value may be null.

getIconResId

Added in API level 35
fun getIconResId(): Int

Gets the resource id of the drawable icon for this rule.

getInterruptionFilter

Added in API level 24
fun getInterruptionFilter(): Int

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

getName

Added in API level 24
fun getName(): String!

Returns the name of this rule.

getOwner

Added in API level 24
fun getOwner(): ComponentName!

Returns the ComponentName of the condition provider service that owns this rule.

getTriggerDescription

Added in API level 35
fun getTriggerDescription(): String?

Gets the user visible description of when this rule is active (see Condition.STATE_TRUE).

Return
String? This value may be null.

getZenPolicy

Added in API level 29
fun getZenPolicy(): ZenPolicy?

Gets the ZenPolicy applied if getInterruptionFilter() is NotificationManager.INTERRUPTION_FILTER_PRIORITY.

Return
ZenPolicy? This value may be null.

hashCode

Added in API level 24
fun hashCode(): Int
Return
Int a hash code value for this object.

isEnabled

Added in API level 24
fun isEnabled(): Boolean

Returns whether this rule is enabled.

isManualInvocationAllowed

Added in API level 35
fun isManualInvocationAllowed(): Boolean

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

setConditionId

Added in API level 24
fun setConditionId(conditionId: Uri!): Unit

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

setConfigurationActivity

Added in API level 29
fun setConfigurationActivity(componentName: ComponentName?): Unit

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 the owner supplied in the constructor; 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
componentName ComponentName?: This value may be null.

setDeviceEffects

Added in API level 35
fun setDeviceEffects(deviceEffects: ZenDeviceEffects?): Unit

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

Added in API level 24
fun setEnabled(enabled: Boolean): Unit

Enables this rule.

setInterruptionFilter

Added in API level 24
fun setInterruptionFilter(interruptionFilter: Int): Unit

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

Parameters
interruptionFilter Int: The do not disturb mode to enter when this rule is active. Value is android.app.NotificationManager#INTERRUPTION_FILTER_NONE, android.app.NotificationManager#INTERRUPTION_FILTER_PRIORITY, android.app.NotificationManager#INTERRUPTION_FILTER_ALARMS, android.app.NotificationManager#INTERRUPTION_FILTER_ALL, or android.app.NotificationManager#INTERRUPTION_FILTER_UNKNOWN

setName

Added in API level 24
fun setName(name: String!): Unit

Sets the name of this rule.

setZenPolicy

Added in API level 29
fun setZenPolicy(zenPolicy: ZenPolicy?): Unit

Sets the ZenPolicy applied if getInterruptionFilter() is NotificationManager.INTERRUPTION_FILTER_PRIORITY.

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

Parameters
zenPolicy ZenPolicy?: This value may be null.

toString

Added in API level 24
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 24
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 24
static val CREATOR: Parcelable.Creator<AutomaticZenRule!>