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:
- Create a
Notification.Builderfor the notification. - Create an
ProjectedExtender. - Set projection-specific properties using the
setmethods on theProjectedExtender. - Call
Notification.Builder.extendto 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(notification: Notification)Creates an |
|
| Public methods | |
|---|---|
| Notification.Builder |
extend(builder: Notification.Builder)Applies the Projected extensions to the notification builder. |
| PendingIntent? |
Returns the |
| Notification.ProjectedExtender |
setContentIntent(intent: PendingIntent?)Sets the |
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. This value cannot be null. |
Public methods
extend
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
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
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. |