Added in API level 37

ProjectedExtender


class ProjectedExtender : Notification.Extender
kotlin.Any
   ↳ 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

Create a ProjectedExtender with default options.

Creates an ProjectedExtender from the extensions in a Notification.

Public methods
Notification.Builder

Applies the Projected extensions to the notification builder.

PendingIntent?

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

Notification.ProjectedExtender

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

Public constructors

ProjectedExtender

Added in API level 37
ProjectedExtender()

Create a ProjectedExtender with default options.

ProjectedExtender

Added in API level 37
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
fun extend(builder: Notification.Builder): Notification.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.
Return
Notification.Builder the modified notification builder.
This value cannot be null.

getContentIntent

Added in API level 37
fun getContentIntent(): PendingIntent?

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

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

setContentIntent

Added in API level 37
fun setContentIntent(intent: PendingIntent?): Notification.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 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.
Return
Notification.ProjectedExtender this ProjectedExtender object for chaining.
This value cannot be null.