public class 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 in your app, and you should always start that when users click the notification. To do this, use the setContentIntent() method.


Public fields


This field is deprecated.

This field was not meant to be public.

Public constructors

This method is deprecated.

use Builder(Context, String) instead.

Builder(@NonNull Context context, @NonNull 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(@NonNull Context context, @NonNull String channelId)


Public methods

@NonNull NotificationCompat.Builder
    int icon,
    @Nullable CharSequence title,
    @Nullable PendingIntent intent

Add an action to this notification.

@NonNull NotificationCompat.Builder

Add an action to this notification.

@NonNull NotificationCompat.Builder

Merge additional metadata into this notification.

@RequiresApi(value = 21) @NonNull NotificationCompat.Builder
    int icon,