WearableExtender
class WearableExtender : NotificationCompat.Extender
kotlin.Any | |
↳ | androidx.core.app.NotificationCompat.WearableExtender |
Helper class to add wearable extensions to notifications.
See Creating Notifications for Android Wear for more information on how to use this class.
To create a notification with wearable extensions:
- Create a
NotificationCompat.Builder
, setting any desired properties. - Create a
NotificationCompat.WearableExtender
. - Set wearable-specific properties using the
add
andset
methods ofNotificationCompat.WearableExtender
. - Call
NotificationCompat.Builder#extend
to apply the extensions to a notification. - Post the notification to the notification system with the
NotificationManagerCompat.notify(...)
methods and not theNotificationManager.notify(...)
methods.
Notification notification = new NotificationCompat.Builder(mContext) .setContentTitle("New mail from " + sender.toString()) .setContentText(subject) .setSmallIcon(R.drawable.new_mail) .extend(new NotificationCompat.WearableExtender() .setContentIcon(R.drawable.new_mail)) .build(); NotificationManagerCompat.from(mContext).notify(0, notification);
Wearable extensions can be accessed on an existing notification by using the WearableExtender(Notification)
constructor, and then using the get
methods to access values.
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(notification); List<Notification> pages = wearableExtender.getPages();
Summary
Constants | |
---|---|
static Int |
Sentinel value for use with |
static Int |
Sentinel value for use with |
static Int |
Size value for use with |
static Int |
Size value for use with |
static Int |
Size value for use with |
static Int |
Size value for use with |
static Int |
Size value for use with |
static Int |
Size value for use with |
static Int |
Sentinel value for an action index that is unset. |
Public constructors | |
---|---|
<init>() Create a |
|
<init>(@NonNull notification: Notification) |
Public methods | |
---|---|
NotificationCompat.WearableExtender |
addAction(@NonNull action: NotificationCompat.Action) Add a wearable action to this notification. |
NotificationCompat.WearableExtender |
addActions(@NonNull actions: MutableList<NotificationCompat.Action!>) Adds wearable actions to this notification. |
NotificationCompat.WearableExtender |
addPage(@NonNull page: Notification) Add an additional page of content to display with this notification. |
NotificationCompat.WearableExtender |
addPages(@NonNull pages: MutableList<Notification!>) Add additional pages of content to display with this notification. |
NotificationCompat.WearableExtender |
Clear all wearable actions present on this builder. |
NotificationCompat.WearableExtender |
Clear all additional pages present on this builder. |
NotificationCompat.WearableExtender |
clone() |
NotificationCompat.Builder |
extend(@NonNull builder: NotificationCompat.Builder) Apply wearable extensions to a notification that is being built. |
MutableList<NotificationCompat.Action!> |
Get the wearable actions present on this notification. |
Bitmap? |
Get a background image to be displayed behind the notification content. |
String? |
Returns the bridge tag of the notification. |
Int |
Get the index of the notification action, if any, that was specified as the primary action. |
Int |
Get an icon that goes with the content of this notification. |
Int |
Get the gravity that the content icon should have within the notification display. |
Boolean |
Get whether the content intent is available when the wearable device is not connected to a companion device. |
Int |
Get the custom height in pixels for the display of this notification's content. |
Int |
Get the custom size preset for the display of this notification out of the available presets found in |
String? |
Returns the dismissal id of the notification. |
PendingIntent? |
Get the intent to launch inside of an activity view when displaying this notification. |
Int |
Get the gravity that this notification should have within the available viewport space. |
Boolean |
Get a hint that this notification's |
Boolean |
Get a hint that this notification's background should not be clipped if possible, and should instead be resized to fully display on the screen, retaining the aspect ratio of the image. |
Boolean |
Get a hint that this notification's content intent will launch an |
Boolean |
Get a hint that this notification's icon should not be displayed. |
Int |
Get the duration, in milliseconds, that the screen should remain on for when this notification is displayed. |
Boolean |
Get a visual hint that only the background image of this notification should be displayed, and other semantic content should be hidden. |