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:
- 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 | |
|---|---|
ProjectedExtender()
Create a |
|
ProjectedExtender(Notification notification)
Creates an |
|
Public methods | |
|---|---|
Notification.Builder
|
extend(Notification.Builder builder)
Applies the Projected extensions to the notification builder. |
PendingIntent
|
getContentIntent()
Returns the |
Notification.ProjectedExtender
|
setContentIntent(PendingIntent intent)
Sets the |
Inherited methods | |
|---|---|
Public constructors
ProjectedExtender
public ProjectedExtender ()
Create a ProjectedExtender with default options.
ProjectedExtender
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
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
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
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. |