NotificationCompat.WearableExtender

public static final class NotificationCompat.WearableExtender
extends Object implements NotificationCompat.Extender

java.lang.Object
   ↳ 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:

  1. Create a NotificationCompat.Builder, setting any desired properties.
  2. Create a NotificationCompat.WearableExtender.
  3. Set wearable-specific properties using the add and set methods of NotificationCompat.WearableExtender.
  4. Call NotificationCompat.Builder.extend(NotificationCompat.Extender) to apply the extensions to a notification.
  5. Post the notification to the notification system with the NotificationManagerCompat.notify(...) methods and not the NotificationManager.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

int SCREEN_TIMEOUT_LONG

This constant is deprecated. This feature is no longer supported.

int SCREEN_TIMEOUT_SHORT

This constant is deprecated. This feature is no longer supported.

int SIZE_DEFAULT

This constant is deprecated. Display intents are no longer supported.

int SIZE_FULL_SCREEN

This constant is deprecated. Display intents are no longer supported.

int SIZE_LARGE

This constant is deprecated. Display intents are no longer supported.

int SIZE_MEDIUM

This constant is deprecated. Display intents are no longer supported.

int SIZE_SMALL

This constant is deprecated. Display intents are no longer supported.

int SIZE_XSMALL

This constant is deprecated. Display intents are no longer supported.

int UNSET_ACTION_INDEX

Sentinel value for an action index that is unset.

Public constructors

WearableExtender()

Create a NotificationCompat.WearableExtender with default options.

WearableExtender(Notification notification)

Public methods

NotificationCompat.WearableExtender addAction(NotificationCompat.Action action)

Add a wearable action to this notification.

NotificationCompat.WearableExtender addActions(List<NotificationCompat.Action> actions)

Adds wearable actions to this notification.

NotificationCompat.WearableExtender addPage(Notification page)

This method is deprecated. Multiple content pages are no longer supported.

NotificationCompat.WearableExtender addPages(List<Notification> pages)

This method is deprecated. Multiple content pages are no longer supported.

NotificationCompat.WearableExtender clearActions()

Clear all wearable actions present on this builder.

NotificationCompat.WearableExtender clearPages()

This method is deprecated. Multiple content pages are no longer supported.

NotificationCompat.WearableExtender clone()
NotificationCompat.Builder extend(NotificationCompat.Builder builder)

Apply wearable extensions to a notification that is being built.

List<NotificationCompat.Action> getActions()

Get the wearable actions present on this notification.

Bitmap getBackground()

This method is deprecated. Background images are no longer supported.

String getBridgeTag()

Returns the bridge tag of the notification.

int getContentAction()

Get the index of the notification action, if any, that was specified as the primary action.

int getContentIcon()

This method is deprecated. This method has no effect starting with Wear 2.0.

int getContentIconGravity()

This method is deprecated. This method has no effect starting with Wear 2.0.

boolean getContentIntentAvailableOffline()

Get whether the content intent is available when the wearable device is not connected to a companion device.

int getCustomContentHeight()

This method is deprecated. This method has no effect starting with Wear 2.0.

int getCustomSizePreset()

This method is deprecated. This method has no effect starting with Wear 2.0.

String getDismissalId()

Returns the dismissal id of the notification.

PendingIntent getDisplayIntent()

This method is deprecated. Display intents are no longer supported.