NotificationCompat.Builder

public static class NotificationCompat.Builder
extends Object

java.lang.Object
   ↳ androidx.core.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 is deprecated. This field was not meant to be public.

Public constructors

Builder(Context context, Notification notification)

Creates a NotificationCompat.Builder which can be used to build a notification that is equivalent to the given one, such that updates can be made to an existing notification with the NotitifactionCompat.Builder API.

Builder(Context context, String channelId)

Constructor.

Builder(Context context)

This constructor is deprecated. use Builder(Context, String) instead. All posted notifications must specify a NotificationChannel ID.

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.