NotificationCompat.ProjectedExtender


class NotificationCompat.ProjectedExtender : 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 functions

NotificationCompat.Builder

Applies the Project extensions to the notification builder.

PendingIntent?

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

NotificationCompat.ProjectedExtender

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

Public constructors

ProjectedExtender

ProjectedExtender()

Create a ProjectedExtender with default options.

ProjectedExtender

ProjectedExtender(notification: Notification)

Creates an ProjectedExtender from the extensions in a Notification.

Parameters
notification: Notification

the notification to extract extensions from.

Public functions

extend

fun extend(builder: NotificationCompat.Builder): NotificationCompat.Builder

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

Parameters
builder: NotificationCompat.Builder

the notification builder to extend

Returns
NotificationCompat.Builder

the modified notification builder

getContentIntent

fun getContentIntent(): PendingIntent?

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

Returns
PendingIntent?

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

setContentIntent

fun setContentIntent(intent: PendingIntent?): NotificationCompat.ProjectedExtender

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
intent: PendingIntent?

the PendingIntent to fire on tap

Returns
NotificationCompat.ProjectedExtender

this ProjectedExtender object for chaining