NotificationCompat.ProjectedExtender


public final class NotificationCompat.ProjectedExtender implements NotificationCompat.Extender


Helper class to add projection-specific extensions to a notification. This class is used to specify metadata that is specific to notifications that may be displayed on a Projected device.

To create a notification with Projected extensions:

  1. Create a NotificationCompat.Builder for the notification.
  2. Create an ProjectedExtender.
  3. Set projection-specific properties using the set methods on the ProjectedExtender.
  4. Call extend to apply the extensions to the notification.
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
    .setContentTitle("Example Title")
    .setContentText("Example Text")
    .setSmallIcon(R.drawable.ic_notification);

ProjectedExtender projectedExtender = new ProjectedExtender()
    .setContentIntent(projectedTapIntent);

builder.extend(projectedExtender);
notificationManager.notify(NOTIFICATION_ID, builder.build());

Summary

Public constructors

Create a ProjectedExtender with default options.

Creates an ProjectedExtender from the extensions in a Notification.

Public methods

@NonNull NotificationCompat.Builder

Applies the Project extensions to the notification builder.

@Nullable PendingIntent

Returns the PendingIntent to be fired when the notification is tapped on the Projected device.

@NonNull NotificationCompat.ProjectedExtender

Sets the PendingIntent to be opened on the Projected device when the notification is tapped on the that device.

Public constructors

ProjectedExtender

public ProjectedExtender()

Create a ProjectedExtender with default options.

ProjectedExtender

public ProjectedExtender(@NonNull Notification notification)

Creates an ProjectedExtender from the extensions in a Notification.

Parameters
@NonNull Notification notification

the notification to extract extensions from.

Public methods

extend

public @NonNull NotificationCompat.Builder extend(@NonNull NotificationCompat.Builder builder)

Applies the Project extensions to the notification builder. This method is called by the extend method and should not be called directly.

Parameters
@NonNull NotificationCompat.Builder builder

the notification builder to extend

Returns
@NonNull NotificationCompat.Builder

the modified notification builder

getContentIntent

public @Nullable PendingIntent getContentIntent()

Returns the PendingIntent to be fired when the notification is tapped on the Projected device.

Returns
@Nullable PendingIntent

the PendingIntent to fire on tap, or null if not set

setContentIntent

public @NonNull NotificationCompat.ProjectedExtender setContentIntent(@Nullable PendingIntent intent)

Sets the PendingIntent to be opened on the Projected device when the notification is tapped on the that device. This is distinct from the notification's main contentIntent, which is typically fired when the notification is tapped on the host device (e.g., the phone).

Parameters
@Nullable PendingIntent intent

the PendingIntent to fire on tap

Returns
@NonNull NotificationCompat.ProjectedExtender

this ProjectedExtender object for chaining