added in version 22.1.0
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1

NotificationCompat.WearableExtender

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

java.lang.Object
   ↳ android.support.v4.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 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

Sentinel value for use with setHintScreenTimeout(int) to keep the screen on for a longer amount of time when this notification is displayed on the screen.

int SCREEN_TIMEOUT_SHORT

Sentinel value for use with setHintScreenTimeout(int) to keep the screen on for a short amount of time when this notification is displayed on the screen.

int SIZE_DEFAULT

Size value for use with setCustomSizePreset(int) to show this notification with default sizing.

int SIZE_FULL_SCREEN

Size value for use with setCustomSizePreset(int) to show this notification full screen.

int SIZE_LARGE

Size value for use with setCustomSizePreset(int) to show this notification with a large size.

int SIZE_MEDIUM

Size value for use with setCustomSizePreset(int) to show this notification with a medium size.

int SIZE_SMALL

Size value for use with setCustomSizePreset(int) to show this notification with a small size.

int SIZE_XSMALL

Size value for use with setCustomSizePreset(int) to show this notification with an extra small size.

int UNSET_ACTION_INDEX

Sentinel value for an action index that is unset.

Public constructors

NotificationCompat.WearableExtender()

Create a NotificationCompat.WearableExtender with default options.

NotificationCompat.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.