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 |
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 |
static Int |
Rule is of an unknown type. |
Inherited constants | |
---|---|
Public constructors | |
---|---|
AutomaticZenRule(name: String!, owner: ComponentName!, conditionId: Uri!, interruptionFilter: Int, enabled: Boolean) Creates an automatic zen rule. |
|
AutomaticZenRule(name: String, owner: ComponentName?, configurationActivity: ComponentName?, conditionId: Uri, policy: ZenPolicy?, interruptionFilter: Int, enabled: Boolean) Creates an automatic zen rule. |
|
AutomaticZenRule(source: Parcel!) |
Public methods | |
---|---|
Int | |
Boolean |
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 |
Long |
Returns the time this rule was created, represented as milliseconds since the epoch. |
ZenDeviceEffects? |
Gets the |
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! |
getName() Returns the name of this rule. |
ComponentName! |
getOwner() Returns the |
String? |
Gets the user visible description of when this rule is active (see |
Int |
getType() Gets the type of the rule. |
ZenPolicy? |
Gets the zen policy. |
Int |
hashCode() |
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 |
setConfigurationActivity(componentName: ComponentName?) Sets the configuration activity - an activity that handles |
Unit |
setDeviceEffects(deviceEffects: ZenDeviceEffects?) Sets the |
Unit |
setEnabled(enabled: Boolean) Enables this rule. |
Unit |
setInterruptionFilter(interruptionFilter: Int) Sets the interruption filter that is applied when this rule is active. |
Unit |
Sets the name of this rule. |
Unit |
setZenPolicy(zenPolicy: ZenPolicy?) Sets the zen policy. |
String |
toString() |
Unit |
writeToParcel(dest: Parcel, flags: Int) |
Properties | |
---|---|
static Parcelable.Creator<AutomaticZenRule!> |
Constants
TYPE_BEDTIME
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
static val TYPE_DRIVING: Int
The type for rules triggered by driving detection, like Bluetooth connections or vehicle sounds.
Value: 4
TYPE_IMMERSIVE
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
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
static val TYPE_OTHER: Int
Rule is of a known type, but not one of the specific types.
Value: 0
TYPE_SCHEDULE_CALENDAR
static val TYPE_SCHEDULE_CALENDAR: Int
The type for rules triggered by calendar events.
Value: 2
TYPE_SCHEDULE_TIME
static val TYPE_SCHEDULE_TIME: Int
The type for rules triggered according to a time-based schedule.
Value: 1
TYPE_THEATER
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
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 lower than the calling app's targetSdk.
Value: -1
Public constructors
AutomaticZenRule
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. |
AutomaticZenRule
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. |
Public methods
describeContents
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
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 returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
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
fun getConditionId(): Uri!
Returns the representation of the state that causes this rule to become active.
getConfigurationActivity
fun getConfigurationActivity(): ComponentName?
Returns the ComponentName
of the activity that shows configuration options for this rule.
Return | |
---|---|
ComponentName? |
This value may be null . |
getCreationTime
fun getCreationTime(): Long
Returns the time this rule was created, represented as milliseconds since the epoch.
getDeviceEffects
fun getDeviceEffects(): ZenDeviceEffects?
Gets the ZenDeviceEffects
of this rule.
Return | |
---|---|
ZenDeviceEffects? |
This value may be null . |
getIconResId
fun getIconResId(): Int
Gets the resource id of the drawable icon for this rule.
getInterruptionFilter
fun getInterruptionFilter(): Int
Returns the interruption filter that is applied when this rule is active.
getOwner
fun getOwner(): ComponentName!
Returns the ComponentName
of the condition provider service that owns this rule.
getTriggerDescription
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 . |
getType
fun getType(): Int
Gets the type of the rule.
getZenPolicy
fun getZenPolicy(): ZenPolicy?
Gets the zen policy.
Return | |
---|---|
ZenPolicy? |
This value may be null . |
isManualInvocationAllowed
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
fun setConditionId(conditionId: Uri!): Unit
Sets the representation of the state that causes this rule to become active.
setConfigurationActivity
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
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 . |
setInterruptionFilter
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 |
setZenPolicy
fun setZenPolicy(zenPolicy: ZenPolicy?): Unit
Sets the zen policy.
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
fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
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 |