Sequenceablepublic final class NotificationRequest extends Object implements Sequenceable
In terms of notification publishing, you must call the setContent(ohos.event.notification.NotificationRequest.NotificationContent) method
to specify the notification content, and call the setDeliveryTime(long) method to set when to deliver
the notification, respectively. NotificationRequest is used as an input parameter in the
NotificationHelper#publishNotification(NotificationRequest) method to publish a notification.
In terms of notification subscription, you can inherit the NotificationSubscriber class and
override the callback methods NotificationSubscriber#onConsumed(NotificationRequest) and
NotificationSubscriber#onCanceled(NotificationRequest). The received or deleted notifications
can be stored in the NotificationRequest object.
NotificationHelper,
NotificationSubscriberSystemCapability.Notification#ANS| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
NotificationRequest.NotificationContent |
Sets the content of a notification to be passed to the
NotificationRequest#setContent(NotificationRequest.NotificationContent) method. |
static class |
NotificationRequest.NotificationConversationalContent |
Constructs a conversation-like notification that includes message communication among multiple users.
|
static class |
NotificationRequest.NotificationLongTextContent |
Constructs notifications that include long text.
|
static class |
NotificationRequest.NotificationMediaContent |
Constructs a media playback notification that can interact with associated audio sessions.
|
static class |
NotificationRequest.NotificationMultiLineContent |
Constructs a notification that includes multiple lines of text.
|
static class |
NotificationRequest.NotificationNormalContent |
Constructs basic notifications.
|
static class |
NotificationRequest.NotificationPictureContent |
Constructs notifications that include a picture attachment.
|
Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
BADGE_STYLE_BIG |
Indicates that the badge of this notification is displayed as a large icon.
|
static int |
BADGE_STYLE_LITTLE |
Indicates that the badge of this notification is displayed as a small icon.
|
static int |
BADGE_STYLE_NONE |
Indicates that the badge of this notification displays only numbers.
|
static String |
CLASSIFICATION_ALARM |
Indicates the classification of notifications for alarms or timers.
|
static String |
CLASSIFICATION_CALL |
Indicates the classification of notifications for incoming calls or similar synchronous communication requests.
|
static String |
CLASSIFICATION_EMAIL |
Indicates the classification of notifications for emails.
|
static String |
CLASSIFICATION_ERROR |
Indicates the classification of notifications for errors occurred during background operations or
identity authentication.
|
static String |
CLASSIFICATION_EVENT |
Indicates the classification of notifications for calendar events.
|
static String |
CLASSIFICATION_MESSAGE |
Indicates the classification of notifications for short messages or instant messages.
|
static String |
CLASSIFICATION_NAVIGATION |
Indicates the classification of notifications for map navigation.
|
static String |
CLASSIFICATION_PROGRESS |
Indicates the classification of notifications for processes that are operated in the background
for a long time.
|
static String |
CLASSIFICATION_PROMO |
Indicates the classification of notifications for advertisement or promotion information.
|
static String |
CLASSIFICATION_RECOMMENDATION |
Indicates the classification of notifications for specific and timely recommendations of
a particular transaction.
|
static String |
CLASSIFICATION_REMINDER |
Indicates the classification of notifications for reminders previously set by the user.
|
static String |
CLASSIFICATION_SERVICE |
Indicates the classification of notifications for ongoing background services.
|
static String |
CLASSIFICATION_SOCIAL |
Indicates the classification of notifications for social network or sharing updates.
|
static String |
CLASSIFICATION_STATUS |
Indicates the classification of notifications for ongoing information about the device and contextual status.
|
static String |
CLASSIFICATION_SYSTEM |
Indicates the classification of notifications for system or device status updates.
|
static String |
CLASSIFICATION_TRANSPORT |
Indicates the classification of notifications for media transport control during playback.
|
static int |
COLOR_DEFAULT |
Indicates the default notification background color, which means that no color is displayed.
|
static String |
EXTRA_USER_INPUT_HISTORY |
getAdditionalData() key: this is the user input history, as supplied to
setNotificationUserInputHistory(java.util.List). |
static int |
GROUP_ALERT_TYPE_ALL |
A notification group alert type, indicating that all notifications in a group have sound or vibration if
sound or vibration is enabled for the associated
NotificationSlot objects. |
static int |
GROUP_ALERT_TYPE_CHILD |
A notification group alert type, indicating that child notifications have sound or vibration but the
overview notification is muted (no sound or vibration) in a group if sound or vibration is enabled for
the associated
NotificationSlot objects. |
static int |
GROUP_ALERT_TYPE_OVERVIEW |
A notification group alert type, indicating that the overview notification has sound or vibration but child
notifications are muted (no sound or vibration) in a group if sound or vibration is enabled for
the associated
NotificationSlot objects. |
static Sequenceable.Producer<NotificationRequest> |
PRODUCER |
Creates a
NotificationRequest instance from a Parcel. |
static int |
VISIBLENESS_TYPE_NO_OVERRIDE |
Indicates that the notification display effect has not been set by
setVisibleness(int). |
static int |
VISIBLENESS_TYPE_PRIVATE |
Indicates that only the basic information, such as application icon and
application name is displayed on the lock screen.
|
static int |
VISIBLENESS_TYPE_PUBLIC |
Indicates that contents of a notification are displayed on the lock screen.
|
static int |
VISIBLENESS_TYPE_SECRET |
Indicates that notifications are not displayed on the lock screen.
|
| 构造器 | 说明 |
|---|---|
NotificationRequest() |
Default constructor used to create a
NotificationRequest instance. |
NotificationRequest(int notificationId) |
A constructor used to create a
NotificationRequest instance with the input parameter
notificationId passed. |
NotificationRequest(Context context,
int notificationId) |
A constructor used to create a
NotificationRequest instance based on the specified context and
notification ID. |
NotificationRequest(NotificationRequest request) |
A constructor used to create a
NotificationRequest instance by copying parameters from
an existing one. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
NotificationRequest |
addActionButton(NotificationActionButton actionButton) |
Adds a
NotificationActionButton to this notification. |
NotificationRequest |
addMessageUser(MessageUser messageUser) |
Adds a
MessageUser object and associates it with this notification. |
List<NotificationActionButton> |
getActionButtons() |
Obtains the list of all
NotificationActionButton objects included in this notification. |
IntentParams |
getAdditionalData() |
Obtains the
IntentParams object set in the notification. |
long |
getAutoDeletedTime() |
Obtains the period during which a notification is deleted.
|
int |
getBadgeIconStyle() |
Obtains the badge icon style of this notification.
|
int |
getBadgeNumber() |
Obtains the number to be displayed for this notification.
|
PixelMap |
getBigIcon() |
Obtains the large icon of this notification.
|
String |
getClassification() |
Obtains the classification of this notification.
|
int |
getColor() |
Obtains the background color of this notification.
|
NotificationRequest.NotificationContent |
getContent() |
Obtains the notification content set by calling the
setContent(ohos.event.notification.NotificationRequest.NotificationContent) method. |
long |
getCreateTime() |
已过时。
This change is effective since API version 2. The time when a
NotificationRequest is
initialized is not accessible to the public. To obtain the time when a notification is delivered,
call the getDeliveryTime() method. |
String |
getCreatorBundleName() |
Obtains the bundle name of the notification creator.
|
int |
getCreatorPid() |
Obtains the PID of the notification creator.
|
int |
getCreatorUid() |
Obtains the UID of the notification creator.
|
ComponentProvider |
getCustomBigView() |
Obtains the
ComponentProvider object defining the custom view to
be displayed when this notification is expanded. |
ComponentProvider |
getCustomFloatView() |
Obtains the
ComponentProvider object defining the custom view to be
displayed when this notification is shown as a floating window at the top of the screen. |
ComponentProvider |
getCustomView() |
Obtains the
ComponentProvider object defining the custom view set in
this notification. |
long |
getDeliveryTime() |
Obtains the time when a notification is delivered.
|
int |
getGroupAlertType() |
Obtains the group alert type of this notification.
|
String |
getGroupValue() |
Obtains the group information about this notification.
|
IntentAgent |
getIntentAgent() |
Obtains the
IntentAgent contained in this notification. |
String |
getLabel() |
Obtains the label of this notification.
|
PixelMap |
getLittleIcon() |
Obtains the icon of the notification.
|
IntentAgent |
getMaxScreenIntentAgent() |
Obtains the full-screen
IntentAgent set
by calling setMaxScreenIntentAgent(ohos.event.intentagent.IntentAgent). |
List<MessageUser> |
getMessageUsers() |
Obtains all
MessageUser objects associated with this notification. |
String |
getNotificationHashCode() |
Obtains the unique hash code of a notification in the current application.
|
int |
getNotificationId() |
Obtains the notification ID, which is unique in the current application.
|
int |
getNotificationType() |
Obtains the notification type.
|
String |
getOwnerBundleName() |
Obtains the bundle name of the notification owner.
|
int |
getProgressMax() |
Obtains the maximum value displayed for the progress bar of this notification.
|
int |
getProgressValue() |
Obtains the current value displayed for the progress bar of this notification.
|
IntentAgent |
getRemovalIntentAgent() |
Obtains the
IntentAgent object that is triggered when
the user explicitly removes this notification. |
String |
getSettingsText() |
Obtains the text that will be displayed as a link to the settings of the application.
|
String |
getShortcutId() |
Obtains the shortcut ID associated with this notification.
|
String |
getSlotId() |
Obtains the slot ID of a notification set by calling the
setSlotId(java.lang.String) method. |
String |
getSortingKey() |
Obtains the key used for sorting notifications from the same application bundle.
|
String |
getStatusBarText() |
Obtains the scrolling text that will be displayed in the status bar when this notification is received.
|
int |
getVisibleness() |
Obtains the display effect of this notification on the lock screen.
|
boolean |
isAlertOneTime() |
Checks whether this notification is set to alert only once, which means that sound or vibration
will no longer be played for notifications with the same ID upon their updates.
|
boolean |
isColorEnabled() |
Checks whether background color is enabled for this notification.
|
boolean |
isCountdownTimer() |
Checks whether the notification creation time is displayed as a countdown timer.
|
boolean |
isFloatingIcon() |
Checks whether this notification is displayed as a floating icon on top of the screen.
|
boolean |
isGroupOverview() |
Checks whether this notification is the group overview.
|
boolean |
isInProgress() |
Checks whether this notification is in progress.
|
boolean |
isOnlyLocal() |
Checks whether this notification is relevant only to the local device and cannot be displayed on
remote devices.
|
boolean |
isPermitSystemGeneratedContextualActionButtons() |
Checks whether the platform is allowed to generate contextual
NotificationActionButton objects for
this notification. |
boolean |
isProgressIndeterminate() |
Checks whether the progress bar of this notification is indeterminate.
|
boolean |
isShowCreateTime() |
已过时。
This change is effective since API version 2. Use
isShowDeliveryTime() instead. A
notification displays the time when it is delivered, rather than the time when it is created. |
boolean |
isShowDeliveryTime() |
Checks whether the notification delivery time is displayed for this notification.
|
boolean |
isShowStopwatch() |
Checks whether the notification creation time is displayed as a stopwatch.
|
boolean |
isTapDismissed() |
Checks whether the current notification will be automatically dismissed after being tapped.
|
boolean |
isUnremovable() |
Checks whether this notification is unremovable.
|
boolean |
marshalling(Parcel out) |
Marshals a
NotificationRequest object into a Parcel. |
NotificationRequest |
setAdditionalData(IntentParams extras) |
Sets extra parameters that are stored as key-value pairs for the notification.
|
NotificationRequest |
setAlertOneTime(boolean isAlertOnce) |
Sets whether to have this notification alert only once.
|
NotificationRequest |
setAutoDeletedTime(long time) |
Sets the time to delete a notification.
|
NotificationRequest |
setBadgeIconStyle(int badgeIconStyle) |
Sets the badge icon style for this notification.
|
NotificationRequest |
setBadgeNumber(int number) |
Sets the number to be displayed for this notification.
|
NotificationRequest |
setBigIcon(PixelMap bigIcon) |
Sets the large icon of this notification, which is usually displayed on the right of the notification.
|
NotificationRequest |
setClassification(String classification) |
Sets the classification of this notification, which describes the purpose of this notification.
|
NotificationRequest |
setColor(int color) |
Sets the background color of this notification.
|
NotificationRequest |
setColorEnabled(boolean colorEnabled) |
Sets whether to enable background color for this notification.
|
NotificationRequest |
setContent(NotificationRequest.NotificationContent content) |
Sets the notification content type to
NotificationRequest.NotificationNormalContent,
NotificationRequest.NotificationLongTextContent, or
NotificationRequest.NotificationPictureContent. |
NotificationRequest |
setCountdownTimer(boolean isCountDown) |
Sets whether to show the notification creation time as a countdown timer.
|
NotificationRequest |
setCreateTime(long createTime) |
已过时。
This change is effective since API version 2. The
createTime takes the system time when a
NotificationRequest is initialized. |
NotificationRequest |
setCustomBigView(ComponentProvider view) |
Sets the custom view to be displayed when this notification is expanded.
|
NotificationRequest |
setCustomFloatView(ComponentProvider view) |
Sets the custom view to be displayed when this notification is shown as a
floating window at the top of the screen.
|
NotificationRequest |
setCustomView(ComponentProvider view) |
Sets the custom view of this notification.
|
NotificationRequest |
setDeliveryTime(long deliveryTime) |
Sets the time to deliver a notification.
|
NotificationRequest |
setGroupAlertType(int groupAlertType) |
Sets the group alert type for this notification, which determines how the group overview and
other notifications in a group are published.
|
NotificationRequest |
setGroupOverview(boolean groupOverview) |
Sets whether to use this notification as the overview of its group.
|
NotificationRequest |
setGroupValue(String groupValue) |
Sets the group information for this notification.
|
NotificationRequest |
setInProgress(boolean isOngoing) |
Sets whether this notification is in progress.
|
NotificationRequest |
setIntentAgent(IntentAgent agent) |
Adds an
IntentAgent to this notification. |
NotificationRequest |
setLittleIcon(PixelMap littleIcon) |
Sets the little icon of the notification.
|
NotificationRequest |
setMaxScreenIntentAgent(IntentAgent maxScreenIntentAgent) |
Sets the
IntentAgent to start when the device is not in use,
instead of showing this notification in the status bar. |
NotificationRequest |
setNotificationId(int notificationId) |
Sets the current notification ID to uniquely identify the notification in the application.
|
NotificationRequest |
setNotificationUserInputHistory(List<String> text) |
Sets the most recent
NotificationUserInput records that have been sent through this notification. |
NotificationRequest |
setOnlyLocal(boolean flag) |
Sets whether this notification is relevant only to the local device and cannot be displayed on remote devices.
|
NotificationRequest |
setPermitSystemGeneratedContextualActionButtons(boolean permitted) |
Sets whether to allow the platform to generate contextual
NotificationActionButton objects for
this notification. |
NotificationRequest |
setProgressBar(int progress,
int progressMax,
boolean indeterminate) |
Sets how the progress bar will be displayed for this notification.
|
NotificationRequest |
setPublicNotification(NotificationRequest request) |
Sets an alternative notification to be displayed on the lock screen for this notification.
|
NotificationRequest |
setRemovalIntentAgent(IntentAgent removalIntentAgent) |
Sets an
IntentAgent object that is triggered when
the user explicitly removes this notification. |
NotificationRequest |
setSettingsText(String text) |
Sets the text that will be displayed as a link to the settings of the application.
|
NotificationRequest |
setShortcutId(String shortcutId) |
Sets the shortcut ID for this notification.
|
NotificationRequest |
setShowCreateTime(boolean showCreateTime) |
已过时。
This change is effective since API version 2. A notification displays the time when it is delivered,
rather than the time when it is created. Use
setShowDeliveryTime(boolean) instead. |
NotificationRequest |
setShowDeliveryTime(boolean showDeliveryTime) |
Sets whether to show the notification delivery time for this notification.
|
NotificationRequest |
setShowStopwatch(boolean isStopwatch) |
Sets whether to show the notification creation time as a stopwatch.
|
NotificationRequest |
setSlotId(String slotId) |
Sets the slot ID of a notification to bind the created
NotificationSlot object. |
NotificationRequest |
setSortingKey(String key) |
Sets a key used for sorting notifications from the same application bundle.
|
NotificationRequest |
setStatusBarText(String statusBarText) |
Sets the scrolling text to be displayed in the status bar when this notification is received.
|
NotificationRequest |
setTapDismissed(boolean tapDismissed) |
Sets whether to automatically dismiss a notification after being tapped.
|
NotificationRequest |
setUnremovable(boolean isUnremovable) |
Sets whether this notification is unremovable.
|
NotificationRequest |
setVisibleness(int visibleness) |
Sets the notification display effect, including whether to display this notification on the lock screen,
and how it will be presented if displayed.
|
String |
toString() |
Returns a string representation of the object.
|
boolean |
unmarshalling(Parcel in) |
Unmarshals a
NotificationRequest object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasFileDescriptorpublic static final int BADGE_STYLE_BIG
public static final int BADGE_STYLE_LITTLE
public static final int BADGE_STYLE_NONE
public static final String CLASSIFICATION_ALARM
public static final String CLASSIFICATION_CALL
public static final String CLASSIFICATION_EMAIL
public static final String CLASSIFICATION_ERROR
public static final String CLASSIFICATION_EVENT
public static final String CLASSIFICATION_MESSAGE
public static final String CLASSIFICATION_NAVIGATION
public static final String CLASSIFICATION_PROGRESS
public static final String CLASSIFICATION_PROMO
public static final String CLASSIFICATION_RECOMMENDATION
public static final String CLASSIFICATION_REMINDER
public static final String CLASSIFICATION_SERVICE
public static final String CLASSIFICATION_SOCIAL
public static final String CLASSIFICATION_STATUS
public static final String CLASSIFICATION_SYSTEM
public static final String CLASSIFICATION_TRANSPORT
public static final int COLOR_DEFAULT
public static final String EXTRA_USER_INPUT_HISTORY
getAdditionalData() key: this is the user input history, as supplied to
setNotificationUserInputHistory(java.util.List).public static final int GROUP_ALERT_TYPE_ALL
NotificationSlot objects.setGroupValue(String),
setGroupAlertType(int),
setGroupOverview(boolean),
NotificationSlot,
常量字段值public static final int GROUP_ALERT_TYPE_CHILD
NotificationSlot objects.setGroupValue(String),
setGroupAlertType(int),
setGroupOverview(boolean),
NotificationSlot,
常量字段值public static final int GROUP_ALERT_TYPE_OVERVIEW
NotificationSlot objects.setGroupValue(String),
setGroupAlertType(int),
setGroupOverview(boolean),
NotificationSlot,
常量字段值public static final Sequenceable.Producer<NotificationRequest> PRODUCER
NotificationRequest instance from a Parcel.public static final int VISIBLENESS_TYPE_NO_OVERRIDE
setVisibleness(int). This method is usually not used.public static final int VISIBLENESS_TYPE_PRIVATE
public static final int VISIBLENESS_TYPE_PUBLIC
public static final int VISIBLENESS_TYPE_SECRET
public NotificationRequest(NotificationRequest request)
NotificationRequest instance by copying parameters from
an existing one.request - Indicates the existing NotificationRequest object.public NotificationRequest()
NotificationRequest instance.public NotificationRequest(int notificationId)
NotificationRequest instance with the input parameter
notificationId passed.notificationId - Indicates the notification ID, which must be unique. You can set it to
any int value.public NotificationRequest(Context context, int notificationId)
NotificationRequest instance based on the specified context and
notification ID. To publish a notification with a custom view, you must call such a constructor with
the Context specified.context - Indicates the context of the current application or ability. This parameter cannot be null
if you want to publish a notification with a custom view.notificationId - Indicates the notification ID, which must be unique.
You can set it to any int value.public NotificationRequest setCustomView(ComponentProvider view)
view - Indicates the ComponentProvider object defining the custom view.NotificationRequest object with the custom view.public ComponentProvider getCustomView()
ComponentProvider object defining the custom view set in
this notification. The ComponentProvider object is set in setCustomView(ohos.agp.components.ComponentProvider).ComponentProvider object defining the custom view.public NotificationRequest setCustomBigView(ComponentProvider view)
view - Indicates the ComponentProvider object defining the custom view.NotificationRequest object with the custom view.public ComponentProvider getCustomBigView()
ComponentProvider object defining the custom view to
be displayed when this notification is expanded. The ComponentProvider object is set
in setCustomBigView(ohos.agp.components.ComponentProvider).ComponentProvider object defining the custom view.public NotificationRequest setCustomFloatView(ComponentProvider view)
view - Indicates the ComponentProvider object defining the custom view.NotificationRequest object with the custom view.public ComponentProvider getCustomFloatView()
ComponentProvider object defining the custom view to be
displayed when this notification is shown as a floating window at the top of the screen.
The ComponentProvider object is set in setCustomFloatView(ohos.agp.components.ComponentProvider).ComponentProvider object defining the custom view.public NotificationRequest setOnlyLocal(boolean flag)
NotificationHelper#publishNotification(NotificationRequest) or
NotificationHelper#publishNotification(String, NotificationRequest). Notifications published using
NotificationHelper#publishNotification(NotificationRequest, String) in a distributed system will not
be affected.flag - Specifies whether this notification can be displayed only on the local device. The value
true indicates that it can be displayed only on the local device, and the value false
indicates that it can also be displayed on remote devices.NotificationRequest object with the specified flag.public boolean isOnlyLocal()
true if this notification is relevant only to the local device; returns
false otherwise.public NotificationRequest setSortingKey(String key)
key - Indicates the key to set.NotificationRequest object with the specified key.public String getSortingKey()
public long getAutoDeletedTime()
public String getNotificationHashCode()
To obtain a valid hash code, you must have subscribed to and received the notification. A valid notification hash code is a string composed of multiple attributes separated by an underscore (_), including the notification ID, creator bundle name, creator UID, and owner bundle name.
getNotificationId(),
getCreatorBundleName(),
getCreatorUid(),
getOwnerBundleName()public NotificationRequest setLittleIcon(PixelMap littleIcon)
littleIcon - Indicates the icon of the notification.NotificationRequest object with the specified icon.public PixelMap getLittleIcon()
public NotificationRequest setBigIcon(PixelMap bigIcon)
bigIcon - Indicates the large icon to set. It must be a PixelMap object.NotificationRequest object with the specified bigIcon setting.public PixelMap getBigIcon()
public NotificationRequest setAutoDeletedTime(long time)
time - Indicates the time in milliseconds. The default value is 0, indicating that the
notification will not be automatically deleted. To enable the notification to be automatically deleted,
set this parameter to an integer greater than 0.NotificationRequest object with the specified time.public boolean isTapDismissed()
true if the notification will be automatically dismissed;
returns false otherwise.public NotificationRequest setTapDismissed(boolean tapDismissed)
If you set tapDismissed to true, you must call the
setIntentAgent(ohos.event.intentagent.IntentAgent) method to make the settings take effect.
tapDismissed - Specifies whether a notification will be automatically dismissed after being tapped.
The value true indicates dismissed, and the value false indicates not dismissed.NotificationRequest object with the specified tapDismissed setting.@Deprecated public long getCreateTime()
NotificationRequest is
initialized is not accessible to the public. To obtain the time when a notification is delivered,
call the getDeliveryTime() method.@Deprecated public NotificationRequest setCreateTime(long createTime)
createTime takes the system time when a
NotificationRequest is initialized.NotificationRequest
is the time when it is initialized.createTime - Indicates the time in milliseconds.NotificationRequest object with the specified createTime.@Deprecated public boolean isShowCreateTime()
isShowDeliveryTime() instead. A
notification displays the time when it is delivered, rather than the time when it is created.true if the time is displayed; returns false otherwise.@Deprecated public NotificationRequest setShowCreateTime(boolean showCreateTime)
setShowDeliveryTime(boolean) instead.setCreateTime(long).showCreateTime - Specifies whether to show the notification creation time. The value true
indicates that it is shown, and the value false indicates not.NotificationRequest object with the specified showCreateTime setting.public boolean isShowDeliveryTime()
true if the time is displayed; returns false otherwise.public NotificationRequest setShowDeliveryTime(boolean showDeliveryTime)
setDeliveryTime(long).showDeliveryTime - Specifies whether to show the notification delivery time. The value true
indicates that it is shown, and the value false indicates not.NotificationRequest object with the specified showDeliveryTime setting.public long getDeliveryTime()
public NotificationRequest setDeliveryTime(long deliveryTime)
deliveryTime - Indicates the time in milliseconds.NotificationRequest object with the specified deliveryTime.public IntentAgent getIntentAgent()
IntentAgent contained in this notification.IntentAgent contained in this notification.IntentAgentpublic NotificationRequest setIntentAgent(IntentAgent agent)
IntentAgent to this notification.
After a notification is tapped, subsequent operations such as ability and common events will be triggered
as set by IntentAgent.
agent - Indicates the operation triggered by tapping the notification,
which can be set by IntentAgent.NotificationRequest object with the specified agent.IntentAgentpublic int getNotificationId()
public String getSlotId()
setSlotId(java.lang.String) method.public NotificationRequest setNotificationId(int notificationId)
After a notification is received, its ID is obtained by using the getNotificationId() method.
notificationId - Indicates the ID of the notification to be set. You can set it to any int value.NotificationRequest object with the specified notificationId.public NotificationRequest setSlotId(String slotId)
NotificationSlot object.
You can use NotificationSlot to create a slot object, then set the notification vibration and
lock screen display, and use the current method to bind the slot.
slotId - Indicates the unique ID of the NotificationSlot object. The value must be the ID of
an existing NotificationSlot object. Otherwise, this method does not take effect.NotificationRequest object with the specified slotId.public NotificationRequest.NotificationContent getContent()
setContent(ohos.event.notification.NotificationRequest.NotificationContent) method.public NotificationRequest setContent(NotificationRequest.NotificationContent content)
NotificationRequest.NotificationNormalContent,
NotificationRequest.NotificationLongTextContent, or
NotificationRequest.NotificationPictureContent.
Each content type indicates a particular notification content.
content - Indicates the notification content type.NotificationRequest object with the specified content.public NotificationRequest setAdditionalData(IntentParams extras)
extras - Indicates the IntentParams object containing
the extra parameters in key-value pair format.NotificationRequest object containing extra parameters
specified by extras.public IntentParams getAdditionalData()
IntentParams object set in the notification.IntentParams object.public NotificationRequest setSettingsText(String text)
Calling this method is invalid if the notification content type has been set to
NotificationRequest.NotificationLongTextContent or
NotificationRequest.NotificationPictureContent in the NotificationRequest object
through setContent(ohos.event.notification.NotificationRequest.NotificationContent).
text - Indicates the text to be included. You can set it to any valid link.NotificationRequest object with the specified text.public String getSettingsText()
public int getNotificationType()
NotificationContent#NOTIFICATION_CONTENT_BASIC_TEXT,
NotificationContent#NOTIFICATION_CONTENT_LONG_TEXT,
NotificationContent#NOTIFICATION_CONTENT_PICTURE,
NotificationContent#NOTIFICATION_CONTENT_CONVERSATION,
NotificationContent#NOTIFICATION_CONTENT_MULTILINE, or
NotificationContent#NOTIFICATION_CONTENT_MEDIA.public String getCreatorBundleName()
The notification creator refers to the application that publishes the notification.
public String getOwnerBundleName()
The notification owner refers to the application that subscribes to the notification.
public int getCreatorPid()
The notification creator refers to the application that publishes the notification.
public int getCreatorUid()
The notification creator refers to the application that publishes the notification.
public String getGroupValue()
public NotificationRequest setGroupValue(String groupValue)
If no groups are set for notifications, all notifications from the same application will appear
in the notification bar as one stack with the number of stacked notifications displayed. If notifications
are grouped and there are multiple groups identified by different groupValue, notifications with
different groupValue will appear in separate stacks.
Note that one of the notifications in a group must be set as the overview of its group by calling
setGroupOverview(boolean), and other notifications are considered as child notifications.
Otherwise, notifications will not be displayed as one group even if they are assigned the same
groupValue by calling setGroupValue(java.lang.String).
groupValue - Indicates the group value to be set for this notification.NotificationRequest object with the specified groupValue.public int getGroupAlertType()
public NotificationRequest setGroupAlertType(int groupAlertType)
The group information must have been set by calling setGroupValue(java.lang.String). Otherwise,
this method does not take effect.
groupAlertType - Indicates the group alert type to set, which can be GROUP_ALERT_TYPE_ALL
(default value), GROUP_ALERT_TYPE_OVERVIEW, or GROUP_ALERT_TYPE_CHILD.NotificationRequest object with the specified groupAlertType.public boolean isGroupOverview()
true if this notification is the group overview; returns false otherwise.public NotificationRequest setGroupOverview(boolean groupOverview)
setGroupValue(java.lang.String)
as one stack in the notification bar.
Each group requires only one group overview. After a notification is set as the group overview, it becomes invisible if another notification in the same group is published.
groupOverview - Specifies whether to set this notification as the group overview. The value
true indicates that it is the group overview, ant the value false indicates not.NotificationRequest object with the specified groupOverview setting.public IntentAgent getRemovalIntentAgent()
IntentAgent object that is triggered when
the user explicitly removes this notification.IntentAgent object to be triggered.public NotificationRequest setRemovalIntentAgent(IntentAgent removalIntentAgent)
IntentAgent object that is triggered when
the user explicitly removes this notification.removalIntentAgent - Indicates the IntentAgent object
to be triggered.NotificationRequest object with the specified removalIntentAgent.public String getClassification()
public NotificationRequest setClassification(String classification)
classification - Indicates the notification classification predefined in the system, such as
CLASSIFICATION_CALL or CLASSIFICATION_NAVIGATION.NotificationRequest object with the specified classification.public IntentAgent getMaxScreenIntentAgent()
IntentAgent set
by calling setMaxScreenIntentAgent(ohos.event.intentagent.IntentAgent).IntentAgent.public NotificationRequest setMaxScreenIntentAgent(IntentAgent maxScreenIntentAgent)
IntentAgent to start when the device is not in use,
instead of showing this notification in the status bar.
When the device is in use, the system UI displays a pop-up notification instead of starting
the IntentAgent specified by maxScreenIntentAgent.
Your application must have the ohos.permission.USE_WHOLE_SCREEN permission to use this method.
maxScreenIntentAgent - Indicates the IntentAgent
object containing information about the to-be-started ability that uses the Page template.NotificationRequest object with the specified maxScreenIntentAgent.public int getColor()
The return value, except for the default color COLOR_DEFAULT, is the bitwise OR operation result
of 0xFF000000 and the ARGB value set by setColor(int).
public NotificationRequest setColor(int color)
setColorEnabled(boolean).color - Indicates the background color to set. For details about the value range,
see Color.NotificationRequest object with the specified color.public boolean isColorEnabled()
true if background color is enabled; returns false otherwise.public NotificationRequest setColorEnabled(boolean colorEnabled)
If colorEnabled is set to true, this method takes effect only when the notification
content type has been set to NotificationRequest.NotificationMediaContent in the
NotificationRequest object through NotificationRequest#setContent(NotificationContent) and
an AVToken has been attached to that NotificationMediaContent object through
NotificationMediaContent#setAVToken(AVToken).
colorEnabled - Specifies whether to enable background color. The value true indicates that
background color will be enabled, and the value false indicates not.NotificationRequest object with the specified colorEnabled setting.public int getBadgeNumber()
public NotificationRequest setBadgeNumber(int number)
number - Indicates the number to set.NotificationRequest object with the specified number.public boolean isAlertOneTime()
true if this notification is set to alert only once; returns false otherwise.public NotificationRequest setAlertOneTime(boolean isAlertOnce)
isAlertOnce - Specifies whether to have this notification alert only once. The value true
indicates that this notification will alert only once, and the value false indicates not.NotificationRequest object with the specified isAlertOnce setting.public boolean isShowStopwatch()
true if the time is displayed as a stopwatch; returns false otherwise.public NotificationRequest setShowStopwatch(boolean isStopwatch)
setDeliveryTime(long).
When the notification creation time is set to be shown as a stopwatch, the interval between
the current time and the creation time set by setDeliveryTime(long) is dynamically displayed for
this notification in Minutes: Seconds format. If the interval is longer than 60 minutes,
it will be displayed in Hours: Minutes: Seconds format. If this method and
setShowDeliveryTime(boolean) are both set to true, only this method takes effect, that is,
the notification creation time will be shown as a stopwatch.
isStopwatch - Specifies whether to show the notification creation time as a stopwatch.
The value true indicates that it is shown as a stopwatch, and the value false indicates not.NotificationRequest object with the specified isStopwatch setting.public boolean isCountdownTimer()
true if the time is displayed as a countdown timer; returns false otherwise.public NotificationRequest setCountdownTimer(boolean isCountDown)
setShowStopwatch(boolean) is set to true.isCountDown - Specifies whether to show the notification creation time as a countdown timer. The value
true indicates that it is shown as a countdown timer, and the value false indicates not.NotificationRequest object with the specified isCountDown setting.public boolean isInProgress()
true if this notification is in progress; returns false otherwise.public NotificationRequest setInProgress(boolean isOngoing)
Users cannot directly dismiss notifications in progress because they usually contain some ongoing background services such as music playback.
isOngoing - Specifies whether this notification is in progress. The value true indicates that
the notification is in progress, and the value false indicates not.NotificationRequest object with the specified isOngoing setting.public int getVisibleness()
public NotificationRequest setVisibleness(int visibleness)
For details, see NotificationSlot#setLockscreenVisibleness(int). If the lock screen display effect
is set for a NotificationRequest object and its associated NotificationSlot object, the display
effect set in the NotificationRequest object prevails.
visibleness - Indicates the notification display effect on the lock screen, which can be set to
VISIBLENESS_TYPE_PUBLIC, VISIBLENESS_TYPE_PRIVATE, VISIBLENESS_TYPE_SECRET, or
VISIBLENESS_TYPE_NO_OVERRIDE.NotificationRequest object with the specified visibleness.public int getProgressValue()
public int getProgressMax()
public boolean isProgressIndeterminate()
true if the notification progress bar is indeterminate; returns false
otherwise.public NotificationRequest setProgressBar(int progress, int progressMax, boolean indeterminate)
A progress bar is usually used in notification scenarios such as download.
progress - Indicates the current value displayed for the notification progress bar.progressMax - Indicates the maximum value displayed for the notification progress bar.indeterminate - Specifies whether the progress bar is indeterminate. The value true indicates
that the progress bar is indeterminate, and users cannot see its current and maximum values.NotificationRequest object with the specified progress,
progressMax, and indeterminate settings.public String getStatusBarText()
public NotificationRequest setStatusBarText(String statusBarText)
statusBarText - Indicates the scrolling text to be displayed.NotificationRequest object with the specified statusBarText.public boolean isUnremovable()
true if this notification is unremovable; returns false otherwise.public NotificationRequest setUnremovable(boolean isUnremovable)
If it is set to be unremovable, it cannot be removed by users.
isUnremovable - Specifies whether this notification is unremovable. The value true indicates that
it is unremovable, and the value false indicates removable.NotificationRequest object with the specified isUnremovable setting.public boolean isFloatingIcon()
true if this notification is displayed as a floating icon;
returns false otherwise.public NotificationRequest addActionButton(NotificationActionButton actionButton)
NotificationActionButton to this notification. The system typically places action buttons
next to the notification content.
Each action button must contain an icon, a title, and an IntentAgent.
When a notification is expanded, a maximum of three action buttons can be displayed from left to right
in the order they were added. When the notification is collapsed, no action buttons will be displayed.
actionButton - Indicates the NotificationActionButton object to add.NotificationRequest object with the specified actionButton.public List<NotificationActionButton> getActionButtons()
NotificationActionButton objects included in this notification.NotificationActionButton objects.public NotificationRequest setPublicNotification(NotificationRequest request)
NotificationSlot#setLockscreenVisibleness(int).request - Indicates the alternative notification to be displayed on the lock screen.NotificationRequest object with the specified request.public NotificationRequest setPermitSystemGeneratedContextualActionButtons(boolean permitted)
NotificationActionButton objects for
this notification.permitted - Specifies whether to allow the platform to generate contextual
NotificationActionButton objects. The default value true indicates that the platform
is allowed to generate contextual action buttons, and the value false indicates not.NotificationRequest object with the specified permitted setting.public boolean isPermitSystemGeneratedContextualActionButtons()
NotificationActionButton objects for
this notification.true if the platform is allowed to generate contextual NotificationActionButton
objects; returns false otherwise.public NotificationRequest setNotificationUserInputHistory(List<String> text)
NotificationUserInput records that have been sent through this notification.
The most recent input must be stored in index 0, the second most recent input must be stored in index 1, and so on. The system displays a maximum of five inputs.
text - Indicates the list of inputs to set.NotificationRequest object with the specified text.public List<MessageUser> getMessageUsers()
MessageUser objects associated with this notification.MessageUser objects associated with this notification.public NotificationRequest addMessageUser(MessageUser messageUser)
MessageUser object and associates it with this notification.messageUser - Indicates the MessageUser object to add.NotificationRequest object with the specified messageUser.public String getLabel()
The label is set via NotificationHelper#publishNotification(String, NotificationRequest).
This method returns null if no specific label is set for this notification.
public NotificationRequest setBadgeIconStyle(int badgeIconStyle)
This method does not take effect if the home screen does not support badge icons.
badgeIconStyle - Indicates the type of the badge icon to be displayed for this notification.
The value must be BADGE_STYLE_NONE, BADGE_STYLE_LITTLE, or BADGE_STYLE_BIG.NotificationRequest object with the specified badgeIconStyle.public int getBadgeIconStyle()
public NotificationRequest setShortcutId(String shortcutId)
After a shortcut ID is set for a notification, the notification will be associated with the corresponding home-screen shortcut, and the shortcut will be hidden when the Home application displays the badge or content of the notification.
shortcutId - Indicates the shortcut ID to set.NotificationRequest object with the specified shortcutId.public String getShortcutId()
public boolean marshalling(Parcel out)
NotificationRequest object into a Parcel.
A process can call the unmarshalling(ohos.utils.Parcel) method to unmarshal a
NotificationRequest object from a Parcel to implement
inter-process communication (IPC).
marshalling 在接口中 Sequenceableout - Indicates the MessageParcel object for marshalling.
MessageParcel is a child class of Parcel.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel in)
NotificationRequest object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the MessageParcel object for marshalling.
MessageParcel is a child class of Parcel.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())