| 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.
      
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 
          | 
        
          
          Constructor.
          
         | 
       ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 
          | 
        
          
          Add an action to this notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Add an action to this notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Merge additional metadata into this notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Combine all of the options that have been set and return a new
           
        
           
            Notification
           
          
          object.
          | 
       ||||||||||
| 
          | 
        
          
          Apply an extender to this notification builder.
          
         | 
       ||||||||||
| 
          | 
        
          
          Get the current metadata Bundle used by this notification Builder.
          
         | 
       ||||||||||
| 
          | 
        
          
          
           This method is deprecated.
    Use
            
        
            
             build()
            
           
           instead.
          
          | 
       ||||||||||
| 
          | 
        
          
          Setting this flag will make it so the notification is automatically
 canceled when the user clicks it in the panel.
          
         | 
       ||||||||||
| 
          | 
        
          
          Supply a custom RemoteViews to use instead of the standard one.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the large text at the right-hand side of the notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Supply a
           
        
           
            PendingIntent
           
          
          to send when the notification is clicked.
          | 
       ||||||||||
| 
          | 
        
          
          Set the text (second row) of the notification, in a standard notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the title (first row) of the notification, in a standard notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the default notification options that will be used.
          
         | 
       ||||||||||
| 
          | 
        
          
          Supply a
           
        
           
            PendingIntent
           
          
          to send when the notification is cleared by the user
 directly from the notification panel.
          | 
       ||||||||||
| 
          | 
        
          
          Set metadata for this notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          An intent to launch instead of posting the notification to the status bar.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set this notification to be part of a group of notifications sharing the same key.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set this notification to be the group summary for a group of notifications.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the large icon that is shown in the ticker and notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the argb value that you would like the LED on the device to blnk, as well as the
 rate.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set whether or not this notification is only relevant to the current device.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the large number at the right-hand side of the notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set whether this is an ongoing notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set this flag if you would only like the sound, vibrate
 and ticker to be played if the notification is not already showing.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the relative priority for this notification.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the progress this notification represents, which may be
 represented as a
           
        
           
            ProgressBar
           
          
          .
          | 
       ||||||||||
| 
          | 
        
          
          A variant of
           
        
           
            setSmallIcon(int)
           
          
          that takes an additional
 level parameter for when the icon is a
          
           
            LevelListDrawable
           
          
          .
          | 
       ||||||||||
| 
          | 
        
          
          Set the small icon to use in the notification layouts.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set a sort key that orders this notification among other notifications from the
 same package.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the sound to play.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the sound to play.
          
         | 
       ||||||||||
| 
          | 
        
          
          Add a rich notification style to be applied at build time.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the third line of text in the platform notification template.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the text that is displayed in the status bar when the notification first
 arrives, and also a RemoteViews object that may be displayed instead on some
 devices.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the text that is displayed in the status bar when the notification first
 arrives.
          
         | 
       ||||||||||
| 
          | 
        
          
          Show the
           
        
           
            when
           
          
          field as a stopwatch.
          | 
       ||||||||||
| 
          | 
        
          
          Set the vibration pattern to use.
          
         | 
       ||||||||||
| 
          | 
        
          
          Set the time that the event occurred.
          
         | 
       ||||||||||
| 
         
          [Expand]
         
          
          Inherited Methods
          
         | 
       |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
         
           
         
         From class
         
          java.lang.Object
         
          | 
       |||||||||||
         Constructor.
 Automatically sets the when field to
         
          
           System.currentTimeMillis()
          
         
         and the audio stream to the
         
          
           STREAM_DEFAULT
          
         
         .
        
| context | 
           A
           
            
             Context
            
           
           that will be used to construct the
      RemoteViews. The Context will not be held past the lifetime of this
      Builder object.
           | 
         
|---|
         Add an action to this notification. Actions are typically displayed by
 the system as a button adjacent to the notification content.
         
         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. To ensure that an action button's functionality is always available, first
 implement the functionality in the
         
          
           Activity
          
         
         that starts when a user
 clicks the  notification (see
         
          
           setContentIntent()
          
         
         ), and then
 enhance the notification by implementing the same functionality with
         
          
           addAction()
          
         
         .
        
| action | The action to add. | 
|---|
         Add an action to this notification. Actions are typically displayed by
 the system as a button adjacent to the notification content.
         
         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. To ensure that an action button's functionality is always available, first
 implement the functionality in the
         
          
           Activity
          
         
         that starts when a user
 clicks the  notification (see
         
          
           setContentIntent()
          
         
         ), and then
 enhance the notification by implementing the same functionality with
         
          
           addAction()
          
         
         .
        
| icon | Resource ID of a drawable that represents the action. | 
|---|---|
| title | Text describing the action. | 
| intent | 
           
            
             PendingIntent
            
           
           to be fired when the action is invoked.
           | 
         
Merge additional metadata into this notification.
Values within the Bundle will replace existing extras values in this Builder.
         Combine all of the options that have been set and return a new
         
          
           Notification
          
         
         object.
        
Apply an extender to this notification builder. Extenders may be used to add metadata or change options on this builder.
         Setting this flag will make it so the notification is automatically
 canceled when the user clicks it in the panel.  The PendingIntent
 set with
         
          
           setDeleteIntent(PendingIntent)
          
         
         will be broadcast when the notification
 is canceled.
        
Supply a custom RemoteViews to use instead of the standard one.
Set the large text at the right-hand side of the notification.
         Supply a
         
          
           PendingIntent
          
         
         to send when the notification is clicked.
 If you do not supply an intent, you can now add PendingIntents to individual
 views to be launched when clicked by calling
         
          
           RemoteViews.setOnClickPendingIntent(int,PendingIntent)
          
         
         .  Be sure to
 read
         
          
           Notification.contentIntent
          
         
         for
 how to correctly use this.
        
Set the text (second row) of the notification, in a standard notification.
Set the title (first row) of the notification, in a standard notification.
Set the default notification options that will be used.
         The value should be one or more of the following fields combined with
 bitwise-or:
         
          
           DEFAULT_SOUND
          
         
         ,
         
          
           DEFAULT_VIBRATE
          
         
         ,
         
          
           DEFAULT_LIGHTS
          
         
         .
        
         For all default values, use
         
          
           DEFAULT_ALL
          
         
         .
        
         Supply a
         
          
           PendingIntent
          
         
         to send when the notification is cleared by the user
 directly from the notification panel.  For example, this intent is sent when the user
 clicks the "Clear all" button, or the individual "X" buttons on notifications.  This
 intent is not sent when the application calls
         
          
           NotificationManager.cancel(int)
          
         
         .
        
Set metadata for this notification.
         A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's
 current contents are copied into the Notification each time
         
          
           build()
          
         
         is
 called.
        
         Replaces any existing extras values with those from the provided Bundle.
 Use
         
          
           addExtras(Bundle)
          
         
         to merge in metadata instead.
        
An intent to launch instead of posting the notification to the status bar. Only for use with extremely high-priority notifications demanding the user's immediate attention, such as an incoming phone call or alarm clock that the user has explicitly set to a particular time. If this facility is used for something else, please give the user an option to turn it off and use a normal notification, as this can be extremely disruptive.
| intent | The pending intent to launch. | 
|---|---|
| highPriority | Passing true will cause this notification to be sent even if other notifications are suppressed. | 
Set this notification to be part of a group of notifications sharing the same key. Grouped notifications may display in a cluster or stack on devices which support such rendering.
         To make this notification the summary for its group, also call
         
          
           setGroupSummary(boolean)
          
         
         . A sort order can be specified for group members by using
         
          
           setSortKey(String)
          
         
         .
        
| groupKey | The group key of the group. | 
|---|
         Set this notification to be the group summary for a group of notifications.
 Grouped notifications may display in a cluster or stack on devices which
 support such rendering. Requires a group key also be set using
         
          
           setGroup(String)
          
         
         .
        
| isGroupSummary | Whether this notification should be a group summary. | 
|---|
Set the large icon that is shown in the ticker and notification.
Set the argb value that you would like the LED on the device to blnk, as well as the rate. The rate is specified in terms of the number of milliseconds to be on and then the number of milliseconds to be off.
Set whether or not this notification is only relevant to the current device.
Some notifications can be bridged to other devices for remote display. This hint can be set to recommend this notification not be bridged.
Set the large number at the right-hand side of the notification. This is equivalent to setContentInfo, although it might show the number in a different font size for readability.
Set whether this is an ongoing notification.
Ongoing notifications differ from regular notifications in the following ways:
Set this flag if you would only like the sound, vibrate and ticker to be played if the notification is not already showing.
Set the relative priority for this notification. Priority is an indication of how much of the user's valuable attention should be consumed by this notification. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification. The system sets a notification's priority based on various factors including the setPriority value. The effect may differ slightly on different platforms.
| pri | 
           Relative priority for this notification. Must be one of
     the priority constants defined by
           
            
             NotificationCompat
            
           
           .
     Acceptable values range from
           
            
             PRIORITY_MIN
            
           
           (-2) to
           
            
             PRIORITY_MAX
            
           
           (2).
           | 
         
|---|
         Set the progress this notification represents, which may be
 represented as a
         
          
           ProgressBar
          
         
         .
        
         A variant of
         
          
           setSmallIcon(int)
          
         
         that takes an additional
 level parameter for when the icon is a
         
          
           LevelListDrawable
          
         
         .
        
| icon | A resource ID in the application's package of the drawble to use. | 
|---|---|
| level | The level to use for the icon. | 
Set the small icon to use in the notification layouts. Different classes of devices may return different sizes. See the UX guidelines for more information on how to design these icons.
| icon | A resource ID in the application's package of the drawble to use. | 
|---|
Set a sort key that orders this notification among other notifications from the same package. This can be useful if an external sort was already applied and an app would like to preserve this. Notifications will be sorted lexicographically using this value, although providing different priorities in addition to providing sort key may cause this value to be ignored.
         This sort key can also be used to order members of a notification group. See
         
          
           setGroup(String)
          
         
         .
        
Set the sound to play. It will play on the default stream.
Set the sound to play. It will play on the stream you supply.
           
            STREAM_DEFAULT
           
          
         
           
            for the
           
          
          
           STREAM_
          
          constants.
         
         Add a rich notification style to be applied at build time.
         
         If the platform does not provide rich notification styles, this method has no effect. The
 user will always see the normal notification style.
        
| style | Object responsible for modifying the notification style. | 
|---|
         Set the third line of text in the platform notification template.
 Don't use if you're also using
         
          
           setProgress(int, int, boolean)
          
         
         ;
 they occupy the same location in the standard template.
         
         If the platform does not provide large-format notifications, this method has no effect.
 The third line of text only appears in expanded view.
         
        
Set the text that is displayed in the status bar when the notification first arrives, and also a RemoteViews object that may be displayed instead on some devices.
Set the text that is displayed in the status bar when the notification first arrives.
         Show the
         
          
           when
          
         
         field as a stopwatch.
 Instead of presenting
         
          when
         
         as a timestamp, the notification will show an
 automatically updating display of the minutes and seconds since
         
          when
         
         .
 Useful when showing an elapsed time (like an ongoing phone call).
        
Set the vibration pattern to use.
           
            for a discussion of the
           
          
          
           pattern
          
          parameter.
         Set the time that the event occurred. Notifications in the panel are sorted by this time.