Sequenceablepublic final class NotificationSlot extends Object implements Sequenceable
An application can be associated with one or more NotificationSlot instances.
SystemCapability.Notification#ANSSequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
LEVEL_DEFAULT |
Indicates that the notification function is enabled and notification icons are displayed
in the status bar, with no banner but with a prompt tone.
|
static int |
LEVEL_HIGH |
Indicates that the notification function is enabled and notification icons are displayed
in the status bar, with a banner and a prompt tone.
|
static int |
LEVEL_LOW |
Indicates that the notification function is enabled and notification icons are displayed
in the status bar, with no banner or prompt tone.
|
static int |
LEVEL_MIN |
Indicates that the notification function is enabled but notification icons are not displayed
in the status bar, with no banner or prompt tone.
|
static int |
LEVEL_NONE |
Indicates that the notification function is disabled.
|
static int |
LEVEL_UNDEFINED |
Indicates that the user does not define an level.
|
static Sequenceable.Producer<NotificationSlot> |
PRODUCER |
Creates a
NotificationSlot instance from a Parcel. |
| 构造器 | 说明 |
|---|---|
NotificationSlot(String id,
String name,
int level) |
A constructor used to initialize the ID, name, and level of a
NotificationSlot object. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
canEnableLight() |
Obtains whether the notification light is enabled in a
NotificationSlot object,
which is set by setEnableLight(boolean). |
boolean |
canVibrate() |
Obtains the vibration status of a
NotificationSlot object,
which is set by setEnableVibration(boolean). |
void |
enableBadge(boolean isShowBadge) |
Sets whether to display application icon badges (digits or dots in the corner of the application icon)
on the home screen after a notification is received.
|
void |
enableBypassDnd(boolean bypassDnd) |
Sets whether to bypass Do not disturb (DND) mode in the system.
|
String |
getDescription() |
Obtains the description of a
NotificationSlot object,
which is set by setDescription(java.lang.String). |
String |
getId() |
Obtains the ID of a
NotificationSlot object. |
int |
getLedLightColor() |
Obtains the color of the notification light in a
NotificationSlot object,
which is set by setLedLightColor(int). |
int |
getLevel() |
Obtains the level of a
NotificationSlot object,
which is set by setLevel(int). |
int |
getLockscreenVisibleness() |
Obtains the notification display effect of a
NotificationSlot object on the
lock screen, which is set by setLockscreenVisibleness(int). |
String |
getName() |
Obtains the name of a
NotificationSlot object. |
String |
getSlotGroup() |
Obtains the ID of the
NotificationSlotGroup object to which this NotificationSlot object
belongs, which is set by setSlotGroup(java.lang.String). |
Uri |
getSound() |
Obtains the prompt tone of a
NotificationSlot object,
which is set by setSound(ohos.utils.net.Uri). |
long[] |
getVibrationStyle() |
Obtains the vibration style of notifications in this
NotificationSlot. |
boolean |
isEnableBypassDnd() |
Obtains whether DND mode is bypassed for a
NotificationSlot object,
which is set by enableBypassDnd(boolean). |
boolean |
isShowBadge() |
Obtains the application icon badge status of a
NotificationSlot object,
which is set by enableBadge(boolean). |
boolean |
marshalling(Parcel out) |
Marshals a
NotificationSlot object into a Parcel. |
void |
setDescription(String description) |
Sets the description for a
NotificationSlot object. |
void |
setEnableLight(boolean isLightEnabled) |
Specifies whether to enable the notification light when a notification is received on the device,
provided that this device has a notification light.
|
void |
setEnableVibration(boolean vibration) |
Sets whether to enable vibration when a notification is received.
|
void |
setLedLightColor(int color) |
Sets the color of the notification light to flash when a notification is received on the device,
provided that this device has a notification light and
setEnableLight(boolean) is called
with the value true. |
void |
setLevel(int level) |
Sets the level of a
NotificationSlot object. |
void |
setLockscreenVisibleness(int visibleness) |
Sets whether and how to display notifications on the lock screen.
|
void |
setName(String name) |
Sets the name of a
NotificationSlot object. |
void |
setSlotGroup(String groupId) |
Binds a
NotificationSlot object to a specified NotificationSlotGroup. |
void |
setSound(Uri sound) |
Sets a prompt tone for a
NotificationSlot object, which will be played
after a notification is received. |
void |
setVibrationStyle(long[] vibrationValues) |
Sets the vibration style for notifications in this
NotificationSlot. |
String |
toString() |
Returns a string representation of the object.
|
boolean |
unmarshalling(Parcel in) |
Unmarshals a
NotificationSlot object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasFileDescriptorpublic static final int LEVEL_DEFAULT
public static final int LEVEL_HIGH
public static final int LEVEL_LOW
public static final int LEVEL_MIN
public static final int LEVEL_NONE
public static final int LEVEL_UNDEFINED
This is a reserved constant. Do not associate it with any notification.
public static final Sequenceable.Producer<NotificationSlot> PRODUCER
NotificationSlot instance from a Parcel.public NotificationSlot(String id, String name, int level)
NotificationSlot object.id - Specifies the ID of the NotificationSlot object. The ID must be unique and
its length must not exceed 1000 characters (the excessive part is automatically truncated).name - Specifies the name of the NotificationSlot object. The name must be visible
to users and its length must not exceed 1000 characters (the excessive part is automatically truncated).level - Specifies the level of the NotificationSlot object, which determines
the notification display effect. The value can be LEVEL_NONE, LEVEL_MIN,
LEVEL_LOW, LEVEL_DEFAULT, or LEVEL_HIGH.public void setLevel(int level)
NotificationSlot object.
setLevel(int level) must be set before the
NotificationHelper#addNotificationSlot(NotificationSlot) method is called.
Otherwise, the settings will not take effect.
level - Specifies the level of the NotificationSlot object, which determines
the notification display effect. The value can be LEVEL_NONE, LEVEL_MIN,
LEVEL_LOW, LEVEL_DEFAULT, or LEVEL_HIGH.public void setName(String name)
NotificationSlot object.
The setting of setName(String) is effective regardless of whether
a NotificationSlot object has been created by
NotificationHelper#addNotificationSlot(NotificationSlot).
name - Specifies the name of the NotificationSlot object. The name is visible to users,
and its length must not exceed 1000 characters (the excessive part is automatically truncated).public void setDescription(String description)
NotificationSlot object.
The setting of setDescription(String) is effective regardless of whether
a NotificationSlot object has been created by
NotificationHelper#addNotificationSlot(NotificationSlot).
description - Describes the NotificationSlot object. The description is visible
to users and its length must not exceed 1000 characters (the excessive part is automatically truncated).public void enableBadge(boolean isShowBadge)
enableBadge(boolean) must be set before the
NotificationHelper#addNotificationSlot(NotificationSlot) method is called.
Otherwise, the settings will not take effect.
isShowBadge - Specifies whether to display the application icon badge.
If the value is true, the application icon badge is enabled; if the value is
false, the application icon badge is disabled.public void enableBypassDnd(boolean bypassDnd)
The setting of enableBypassDnd(boolean) takes effect only when
the Allow interruptions function is enabled for an application in system notification settings.
bypassDnd - Specifies whether to bypass DND mode for an application. If the value
is true, DND mode is bypassed; if the value is false, DND mode is not bypassed.public void setEnableVibration(boolean vibration)
setEnableVibration(boolean) must be set before the
NotificationHelper#addNotificationSlot(NotificationSlot) method is called.
Otherwise, the settings will not take effect.
vibration - Indicates whether to enable vibration when a notification is received.
If the value is true, vibration is enabled; if the value is false,
vibration is disabled.public void setLockscreenVisibleness(int visibleness)
This method specifies different effects for displaying notifications on the lock screen in order to protect user privacy.
The setting takes effect only when the lock screen notifications function is enabled for an application in system notification settings.
visibleness - Specifies the notification display effect on the lock screen,
which can be set to NotificationRequest#VISIBLENESS_TYPE_PUBLIC,
NotificationRequest#VISIBLENESS_TYPE_PRIVATE, or NotificationRequest#VISIBLENESS_TYPE_SECRET.public void setSound(Uri sound)
NotificationSlot object, which will be played
after a notification is received.
setSound(Uri) must be set before the
NotificationHelper#addNotificationSlot(NotificationSlot) method is called.
Otherwise, the settings will not take effect.
sound - Specifies the path for the prompt tone.public void setEnableLight(boolean isLightEnabled)
setEnableLight(boolean) must be set before the
NotificationHelper#addNotificationSlot(NotificationSlot) method is called.
Otherwise, the settings will not take effect.
isLightEnabled - Specifies whether to enable the pulse notification light. The value true
indicates to enable the notification light, and the value false indicates not to enable it.public void setLedLightColor(int color)
setEnableLight(boolean) is called
with the value true.
setLedLightColor(int) must be set before the
NotificationHelper#addNotificationSlot(NotificationSlot) method is called.
Otherwise, the settings will not take effect.
color - Indicates the color of the notification light.public void setSlotGroup(String groupId)
NotificationSlot object to a specified NotificationSlotGroup.
setSlotGroup(String) must be called before the
NotificationHelper#addNotificationSlot(NotificationSlot) method is called. Otherwise,
this method will not take effect.
groupId - Indicates the ID of the NotificationSlotGroup object to bind, which must have been
created by calling NotificationHelper#addNotificationSlotGroup(NotificationSlotGroup).NotificationSlotGrouppublic String getId()
NotificationSlot object.NotificationSlot object,
which is set by NotificationSlot(java.lang.String,java.lang.String,int).public String getName()
NotificationSlot object.NotificationSlot object,
which is set by setName(java.lang.String).public String getDescription()
NotificationSlot object,
which is set by setDescription(java.lang.String).NotificationSlot object.public int getLevel()
NotificationSlot object,
which is set by setLevel(int).NotificationSlot object.public boolean isShowBadge()
NotificationSlot object,
which is set by enableBadge(boolean).true if the application icon badge is enabled;
returns false otherwise.public boolean isEnableBypassDnd()
NotificationSlot object,
which is set by enableBypassDnd(boolean).true if DND mode is bypassed; returns false otherwise.public boolean canVibrate()
NotificationSlot object,
which is set by setEnableVibration(boolean).true if vibration is enabled; returns false otherwise.public int getLockscreenVisibleness()
NotificationSlot object on the
lock screen, which is set by setLockscreenVisibleness(int).NotificationSlot object
on the lock screen.public Uri getSound()
NotificationSlot object,
which is set by setSound(ohos.utils.net.Uri).NotificationSlot object.public boolean canEnableLight()
NotificationSlot object,
which is set by setEnableLight(boolean).true if the notification light is enabled; returns false otherwise.public int getLedLightColor()
NotificationSlot object,
which is set by setLedLightColor(int).public String getSlotGroup()
NotificationSlotGroup object to which this NotificationSlot object
belongs, which is set by setSlotGroup(java.lang.String).NotificationSlotGroup to which this NotificationSlot object
belongs.public void setVibrationStyle(long[] vibrationValues)
NotificationSlot.
If an empty array or null is passed to this method, the system then calls
setEnableVibration(boolean) with the input parameter set to false. If a valid value is passed
to this method, the system calls setEnableVibration(boolean) with the input parameter
set to true.
This method takes effect only before NotificationHelper#addNotificationSlot(NotificationSlot) is called.
vibrationValues - Indicates the vibration style to set.public long[] getVibrationStyle()
NotificationSlot.NotificationSlot.public boolean marshalling(Parcel out)
NotificationSlot object into a Parcel.
A process can call the unmarshalling(ohos.utils.Parcel) method to unmarshal
a NotificationSlot object from a Parcel to implement inter-process
communication (IPC).
marshalling 在接口中 Sequenceableout - Indicates the Parcel object for marshalling.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel in)
NotificationSlot object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.public String toString()
ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())