belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
NotificationCompat.Builder
public
static
class
NotificationCompat.Builder
extends Object
java.lang.Object | |
↳ | android.support.v4.app.NotificationCompat.Builder |
Builder class for NotificationCompat
objects. Allows easier control over
all the flags, as well as help constructing the typical notification layouts.
On platform versions that don't offer expanded notifications, methods that depend on expanded notifications have no effect.
For example, action buttons won't appear on platforms prior to Android 4.1. Action buttons depend on expanded notifications, which are only available in Android 4.1 and later.
For this reason, you should always ensure that UI controls in a notification are also
available in an Activity
in your app, and you should always start that
Activity
when users click the notification. To do this, use the
setContentIntent()
method.
Summary
Fields | |
---|---|
public
ArrayList<String> |
mPeople
This field was deprecated in API level 27.1.0. This field was not meant to be public. |
Public constructors | |
---|---|
NotificationCompat.Builder(Context context, String channelId)
Constructor. |
|
NotificationCompat.Builder(Context context)
This constructor was deprecated
in API level 26.1.0.
use |
Public methods | |
---|---|
NotificationCompat.Builder
|
addAction(NotificationCompat.Action action)
Add an action to this notification. |
NotificationCompat.Builder
|
addAction(int icon, CharSequence title, PendingIntent intent)
Add an action to this notification. |
NotificationCompat.Builder
|
addExtras(Bundle extras)
Merge additional metadata into this notification. |
NotificationCompat.Builder
|
addInvisibleAction(NotificationCompat.Action action)
Add an invisible action to this notification. |
NotificationCompat.Builder
|
addInvisibleAction(int icon, CharSequence title, PendingIntent intent)
Add an invisible action to this notification. |
NotificationCompat.Builder
|
addPerson(String uri)
Add a person that is relevant to this notification. |
Notification
|
build()
Combine all of the options that have been set and return a new |
NotificationCompat.Builder
|
extend(NotificationCompat.Extender extender)
Apply an extender to this notification builder. |
Bundle
|
getExtras()
Get the current metadata Bundle used by this notification Builder. |
Notification
|
getNotification()
This method was deprecated
in API level 22.1.0.
Use |
NotificationCompat.Builder
|
setAutoCancel(boolean autoCancel)
Setting this flag will make it so the notification is automatically canceled when the user clicks it in the panel. |
NotificationCompat.Builder
|
setBadgeIconType(int icon)
Sets which icon to display as a badge for this notification. |
NotificationCompat.Builder
|
setCategory(String category)
Set the notification category. |
NotificationCompat.Builder
|
setChannelId(String channelId)
Specifies the channel the notification should be delivered on. |
NotificationCompat.Builder
|
setColor(int argb)
Sets |
NotificationCompat.Builder
|
setColorized(boolean colorize)
Set whether this notification should be colorized. |
NotificationCompat.Builder
|
setContent(RemoteViews views)
Supply a custom RemoteViews to use instead of the standard one. |
NotificationCompat.Builder
|
setContentInfo(CharSequence info)
Set the large text at the right-hand side of the notification. |
NotificationCompat.Builder
|
setContentIntent(PendingIntent intent)
Supply a |
NotificationCompat.Builder
|
setContentText(CharSequence text)
Set the text (second row) of the notification, in a standard notification. |
NotificationCompat.Builder
|
setContentTitle(CharSequence title)
Set the title (first row) of the notification, in a standard notification. |
NotificationCompat.Builder
|
setCustomBigContentView(RemoteViews contentView)
Supply custom RemoteViews to use instead of the platform template in the expanded form. |
NotificationCompat.Builder
|
setCustomContentView(RemoteViews contentView)
Supply custom RemoteViews to use instead of the platform template. |
NotificationCompat.Builder
|
setCustomHeadsUpContentView(RemoteViews contentView)
Supply custom RemoteViews to use instead of the platform template in the heads up dialog. |
NotificationCompat.Builder
|
setDefaults(int defaults)
Set the default notification options that will be used. |
NotificationCompat.Builder
|
setDeleteIntent(PendingIntent intent)
Supply a |
NotificationCompat.Builder
|
setExtras(Bundle extras)
Set metadata for this notification. |
NotificationCompat.Builder
|
setFullScreenIntent(PendingIntent intent, boolean highPriority)
An intent to launch instead of posting the notification to the status bar. |
NotificationCompat.Builder
|
setGroup(String groupKey)
Set this notification to be part of a group of notifications sharing the same key. |
NotificationCompat.Builder
|
setGroupAlertBehavior(int groupAlertBehavior)
Sets the group alert behavior for this notification. |
NotificationCompat.Builder
|
setGroupSummary(boolean isGroupSummary)
Set this notification to be the group summary for a group of notifications. |
NotificationCompat.Builder
|
setLargeIcon(Bitmap icon)
Set the large icon that is shown in the ticker and notification. |
NotificationCompat.Builder
|
setLights(int argb, int onMs, int offMs)
Set the argb value that you would like the LED on the device to blink, as well as the rate. |
NotificationCompat.Builder
|
setLocalOnly(boolean b)
Set whether or not this notification is only relevant to the current device. |
NotificationCompat.Builder
|
setNumber(int number)
Set the large number at the right-hand side of the notification. |
NotificationCompat.Builder
|
setOngoing(boolean ongoing)
Set whether this is an ongoing notification. |
NotificationCompat.Builder
|
setOnlyAlertOnce(boolean onlyAlertOnce)
Set this flag if you would only like the sound, vibrate and ticker to be played if the notification is not already showing. |
NotificationCompat.Builder
|
setPriority(int pri)
Set the relative priority for this notification. |
NotificationCompat.Builder
|
setProgress(int max, int progress, boolean indeterminate)
Set the progress this notification represents, which may be
represented as a |
NotificationCompat.Builder
|
setPublicVersion(Notification n)
Supply a replacement Notification whose contents should be shown in insecure contexts (i.e. |
NotificationCompat.Builder
|
setRemoteInputHistory(CharSequence[] text)
Set the remote input history. |
NotificationCompat.Builder
|
setShortcutId(String shortcutId)
If this notification is duplicative of a Launcher shortcut, sets the
|
NotificationCompat.Builder
|
setShowWhen(boolean show)
Control whether the timestamp set with |
NotificationCompat.Builder
|
setSmallIcon(int icon, int level)
A variant of |
NotificationCompat.Builder
|
setSmallIcon(int icon)
Set the small icon to use in the notification layouts. |
NotificationCompat.Builder
|
setSortKey(String sortKey)
Set a sort key that orders this notification among other notifications from the same package. |
NotificationCompat.Builder
|
setSound(Uri sound)
Set the sound to play. |
NotificationCompat.Builder
|
setSound(Uri sound, int streamType)
Set the sound to play. |
NotificationCompat.Builder
|
setStyle(NotificationCompat.Style style)
Add a rich notification style to be applied at build time. |
NotificationCompat.Builder
|
setSubText(CharSequence text)
Set the third line of text in the platform notification template. |
NotificationCompat.Builder
|
setTicker(CharSequence tickerText, RemoteViews views)
Sets the "ticker" text which is sent to accessibility services. |
NotificationCompat.Builder
|
setTicker(CharSequence tickerText)
Sets the "ticker" text which is sent to accessibility services. |
NotificationCompat.Builder
|
setTimeoutAfter(long durationMs)
Specifies the time at which this notification should be canceled, if it is not already canceled. |
NotificationCompat.Builder
|
setUsesChronometer(boolean b)
Show the |
NotificationCompat.Builder
|
setVibrate(long[] pattern)
Set the vibration pattern to use. |
NotificationCompat.Builder
|
setVisibility(int visibility)
Sets |
NotificationCompat.Builder
|
setWhen(long when)
Set the time that the event occurred. |
Protected methods | |
---|---|
static
CharSequence
|
limitCharSequenceLength(CharSequence cs)
|
Inherited methods | |
---|---|
![]()
java.lang.Object
|