NotificationUtil
@UnstableApi
class NotificationUtil
Utility methods for displaying Notifications.
Summary
Nested types |
|---|
@DocumentedNotification channel importance levels. |
Constants |
|
|---|---|
const Int |
|
const Int |
IMPORTANCE_HIGH = 4 |
const Int |
IMPORTANCE_LOW = 2 |
const Int |
IMPORTANCE_MIN = 1 |
const Int |
IMPORTANCE_NONE = 0 |
const Int |
IMPORTANCE_UNSPECIFIED = -1000 |
Public functions |
|
|---|---|
java-static Unit |
createNotificationChannel(Creates a notification channel that notifications can be posted to. |
java-static Unit |
setNotification(context: Context!, id: Int, notification: Notification?)Post a notification to be shown in the status bar. |
Constants
IMPORTANCE_UNSPECIFIED
const val IMPORTANCE_UNSPECIFIED = -1000: Int
| See also | |
|---|---|
IMPORTANCE_UNSPECIFIED |
Public functions
createNotificationChannel
java-static fun createNotificationChannel(
context: Context!,
id: String!,
nameResourceId: @StringRes Int,
descriptionResourceId: @StringRes Int,
@NotificationUtil.Importance importance: Int
): Unit
Creates a notification channel that notifications can be posted to. See NotificationChannel and createNotificationChannel for details.
| Parameters | |
|---|---|
context: Context! |
A |
id: String! |
The id of the channel. Must be unique per package. The value may be truncated if it's too long. |
nameResourceId: @StringRes Int |
A string resource identifier for the user visible name of the channel. The recommended maximum length is 40 characters. The string may be truncated if it's too long. You can rename the channel when the system locale changes by listening for the |
descriptionResourceId: @StringRes Int |
A string resource identifier for the user visible description of the channel, or 0 if no description is provided. The recommended maximum length is 300 characters. The value may be truncated if it is too long. You can change the description of the channel when the system locale changes by listening for the |
@NotificationUtil.Importance importance: Int |
The importance of the channel. This controls how interruptive notifications posted to this channel are. One of |
setNotification
java-static fun setNotification(context: Context!, id: Int, notification: Notification?): Unit
Post a notification to be shown in the status bar. If a notification with the same id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information. If notification is null then any notification previously shown with the specified id will be cancelled.
| Parameters | |
|---|---|
context: Context! |
A |
id: Int |
The notification id. |
notification: Notification? |
The |