Builder
open class Builder
| kotlin.Any | |
| ↳ | android.app.Notification.Builder |
Builder class for Notification objects.
Provides a convenient way to set the various fields of a Notification and generate content views using the platform's notification layout template. If your app supports versions of Android as old as API level 4, you can instead use androidx.core.app.NotificationCompat.Builder, available in the Android Support library.
Example:
Notification noti = new Notification.Builder(mContext) .setContentTitle("New mail from " + sender.toString()) .setContentText(subject) .setSmallIcon(R.drawable.new_mail) .setLargeIcon(aBitmap) .build();
Summary
| Public constructors | |
|---|---|
|
Constructs a new Builder with the defaults: |
|
| Public methods | |
|---|---|
| open Notification.Builder |
addAction(action: Notification.Action!)Add an action to this notification. |
| open Notification.Builder! |
addAction(icon: Int, title: CharSequence!, intent: PendingIntent!)Add an action to this notification. |
| open Notification.Builder |
Merge additional metadata into this notification. |
| open Notification.Builder |
Add a person that is relevant to this notification. |
| open Notification.Builder! |
Add a person that is relevant to this notification. |
| open Notification |
build()Combine all of the options that have been set and return a new |
| open RemoteViews! |
Construct a RemoteViews representing the expanded notification layout. |
| open RemoteViews! |
Construct a RemoteViews representing the standard notification layout. |
| open RemoteViews! |
Construct a RemoteViews representing the heads up notification layout. |
| open Notification.Builder |
extend(extender: Notification.Extender!)Apply an extender to this notification builder. |
| open Bundle! |
Get the current metadata Bundle used by this notification Builder. |
| open Notification! | |
| open Notification.Style! |
getStyle()Returns the style set by |
| open static Notification.Builder |
recoverBuilder(context: Context!, n: Notification!)Creates a Builder from an existing notification so further changes can be made. |
| open Notification.Builder |
setActions(vararg actions: Notification.Action!)Alter the complete list of actions attached to this notification. |
| open Notification.Builder |
Determines whether the platform can generate contextual actions for a notification. |
| open Notification.Builder |
setAutoCancel(autoCancel: Boolean)Make this notification automatically dismissed when the user touches it. |
| open Notification.Builder |
setBadgeIconType(icon: Int)Sets which icon to display as a badge for this notification. |
| open Notification.Builder |
Sets the |
| open Notification.Builder |
setCategory(category: String!)Set the notification category. |
| open Notification.Builder |
setChannelId(channelId: String!)Specifies the channel the notification should be delivered on. |
| open Notification.Builder |
setChronometerCountDown(countDown: Boolean)Sets the Chronometer to count down instead of counting up. |
| open Notification.Builder |
Sets |
| open Notification.Builder |
setColorized(colorize: Boolean)Set whether this notification should be colorized. |
| open Notification.Builder! |
setContent(views: RemoteViews!)Supply a custom RemoteViews to use instead of the platform template. |
| open Notification.Builder! |
setContentInfo(info: CharSequence!)A small piece of additional information pertaining to this notification. |
| open Notification.Builder |
setContentIntent(intent: PendingIntent!)Supply a |
| open Notification.Builder |
setContentText(text: CharSequence!)Set the second line of text in the platform notification template. |
| open Notification.Builder |
setContentTitle(title: CharSequence!)Set the first line of text in the platform notification template. |
| open Notification.Builder |
setCustomBigContentView(contentView: RemoteViews!)Supply custom RemoteViews to use instead of the platform template in the expanded form. |
| open Notification.Builder |
setCustomContentView(contentView: RemoteViews!)Supply custom RemoteViews to use instead of the platform template. |
| open Notification.Builder |
setCustomHeadsUpContentView(contentView: RemoteViews!)Supply custom RemoteViews to use instead of the platform template in the heads up dialog. |
| open Notification.Builder! |
setDefaults(defaults: Int)Set which notification properties will be inherited from system defaults. |
| open Notification.Builder |
setDeleteIntent(intent: PendingIntent!)Supply a |
| open Notification.Builder |
Set metadata for this notification. |
| open Notification.Builder |
Set the value for a notification flag |
| open Notification.Builder |
setForegroundServiceBehavior(behavior: Int)Specify a desired visibility policy for a Notification associated with a foreground service. |
| open Notification.Builder |
setFullScreenIntent(intent: PendingIntent!, highPriority: Boolean)An intent to launch instead of posting the notification to the status bar. |
| open Notification.Builder |
Set this notification to be part of a group of notifications sharing the same key. |
| open Notification.Builder |
setGroupAlertBehavior(groupAlertBehavior: Int)Sets the group alert behavior for this notification. |
| open Notification.Builder |
setGroupSummary(isGroupSummary: Boolean)Set this notification to be the group summary for a group of notifications. |
| open Notification.Builder |
setHasSummarizedContent(hasSummarizedContent: Boolean)Sets whether this notification contains text that was computationally summarized from other sources. |
| open Notification.Builder |
setLargeIcon(b: Bitmap!)Add a large icon to the notification content view. |
| open Notification.Builder |
setLargeIcon(icon: Icon!)Add a large icon to the notification content view. |
| open Notification.Builder! |
Set the desired color for the indicator LED on the device, as well as the blink duty cycle (specified in milliseconds). |
| open Notification.Builder |
setLocalOnly(localOnly: Boolean)Set whether or not this notification should not bridge to other devices. |
| open Notification.Builder |
setLocusId(locusId: LocusId?)Sets the |
| open Notification.Builder |
Sets the number of items this notification represents. |
| open Notification.Builder |
setOngoing(ongoing: Boolean)Set whether this is an "ongoing" notification. |
| open Notification.Builder |
setOnlyAlertOnce(onlyAlertOnce: Boolean)Set this flag if you would only like the sound, vibrate and ticker to be played if the notification is not already showing. |
| open Notification.Builder! |
setPriority(pri: Int)Set the priority of this notification. |
| open Notification.Builder |
setProgress(max: Int, progress: Int, indeterminate: Boolean)Set the progress this notification represents. |
| open Notification.Builder |
Supply a replacement Notification whose contents should be shown in insecure contexts (i.e. atop the secure lockscreen). |
| open Notification.Builder |
setRemoteInputHistory(text: Array<CharSequence!>!)Set the remote input history. |
| open Notification.Builder |
setRequestPromotedOngoing(requestPromotedOngoing: Boolean)Set whether this notification is requesting to be a promoted ongoing notification. |
| open Notification.Builder |
setSettingsText(text: CharSequence!)Provides text that will appear as a link to your application's settings. |
| open Notification.Builder |
setShortCriticalText(shortCriticalText: String?)Sets a very short string summarizing the most critical information contained in the notification. |
| open Notification.Builder |
setShortcutId(shortcutId: String!)From Android 11, messaging notifications (those that use |
| open Notification.Builder |
setShowWhen(show: Boolean)Control whether the timestamp set with |
| open Notification.Builder |
setSmallIcon(icon: Icon!)Set the small icon, which will be used to represent the notification in the status bar. |
| open Notification.Builder |
setSmallIcon(icon: Int)Set the small icon resource, which will be used to represent the notification in the status bar. |
| open Notification.Builder |
setSmallIcon(icon: Int, level: Int)A variant of |
| open Notification.Builder |
setSortKey(sortKey: String!)Set a sort key that orders this notification among other notifications from the same package. |
| open Notification.Builder! |
Set the sound to play. |
| open Notification.Builder! |
setSound(sound: Uri!, audioAttributes: AudioAttributes!)Set the sound to play, along with specific |
| open Notification.Builder! |
Set the sound to play, along with a specific stream on which to play it. |
| open Notification.Builder |
setStyle(style: Notification.Style!)Add a rich notification style to be applied at build time. |
| open Notification.Builder |
setSubText(text: CharSequence!)This provides some additional information that is displayed in the notification. |
| open Notification.Builder |
setTicker(tickerText: CharSequence!)Set the "ticker" text which is sent to accessibility services. |
| open Notification.Builder! |
setTicker(tickerText: CharSequence!, views: RemoteViews!)Obsolete version of |
| open Notification.Builder |
setTimeoutAfter(durationMs: Long)Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled. |
| open Notification.Builder |
Show the |
| open Notification.Builder! |
setVibrate(pattern: LongArray!)Set the vibration pattern to use. |
| open Notification.Builder |
setVisibility(visibility: Int)Specify the value of |
| open Notification.Builder |
Add a timestamp pertaining to the notification (usually the time the event occurred). |