Notification.ProjectedExtender


public static final class Notification.ProjectedExtender
extends Object implements Notification.Extender

java.lang.Object
   ↳ android.app.Notification.ProjectedExtender


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 Notification.Builder for the notification.
  2. Create an ProjectedExtender.
  3. Set projection-specific properties using the set methods on the ProjectedExtender.
  4. Call Notification.Builder.extend to apply the extensions to the notification.
 Notification.Builder builder = new Notification.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

ProjectedExtender()

Create a ProjectedExtender with default options.

ProjectedExtender(Notification notification)

Creates an ProjectedExtender from the extensions in a Notification.

Public methods

Notification.Builder extend(Notification.Builder builder)

Applies the Projected extensions to the notification builder.

PendingIntent getContentIntent()

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

Notification.ProjectedExtender setContentIntent(PendingIntent intent)

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

Inherited methods

Public constructors

ProjectedExtender

Added in API level 37
public ProjectedExtender ()

Create a ProjectedExtender with default options.

ProjectedExtender

Added in API level 37
public ProjectedExtender (Notification notification)

Creates an ProjectedExtender from the extensions in a Notification.

Parameters
notification Notification: The notification to extract extensions from.
This value cannot be null.

Public methods

extend

Added in API level 37
public Notification.Builder extend (Notification.Builder builder)

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

Parameters
builder Notification.Builder: the notification builder to extend.
This value cannot be null.

Returns
Notification.Builder the modified notification builder.
This value cannot be null.

getContentIntent

Added in API level 37
public PendingIntent getContentIntent ()

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

Added in API level 37
public Notification.ProjectedExtender setContentIntent (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 Notification.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.
This value may be null.

Returns
Notification.ProjectedExtender this ProjectedExtender object for chaining.
This value cannot be null.