Google は、黒人コミュニティに対する人種平等の促進に取り組んでいます。取り組みを見る

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:

  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 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
static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

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

static Int

Sentinel value for an action index that is unset.

Public constructors

Create a NotificationCompat.WearableExtender with default options.

<init>(@NonNull notification: Notification)

Public methods
NotificationCompat.WearableExtender

Add a wearable action to this notification.

NotificationCompat.WearableExtender

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

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 NotificationCompat.WearableExtender, e.

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 BigPictureStyle (if present) should be converted to low-bit and displayed in ambient mode, especially useful for barcodes and qr codes, as well as other simple black-and-white tickets.

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 Activity directly, telling the platform that it can generate the appropriate transitions

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.

MutableList<Notification!>

Get the array of additional pages of content for displaying this notification.

Boolean

Get whether the scrolling position for the contents of this notification should start at the bottom of the contents instead of the top when the contents are too long to display within the screen.

NotificationCompat.WearableExtender
setBackground(@Nullable background: Bitmap?)

Set a background image to be displayed behind the notification content.

NotificationCompat.WearableExtender
setBridgeTag(@Nullable bridgeTag: String?)

Sets a bridge tag for this notification.

NotificationCompat.WearableExtender
setContentAction(actionIndex: Int)

Set an action from this notification's actions as the primary action.

NotificationCompat.WearableExtender

Set an icon that goes with the content of this notification.

NotificationCompat.WearableExtender
setContentIconGravity(contentIconGravity: Int)

Set the gravity that the content icon should have within the notification display.

NotificationCompat.WearableExtender
setContentIntentAvailableOffline(contentIntentAvailableOffline: Boolean)

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

NotificationCompat.WearableExtender

Set the custom height in pixels for the display of this notification's content.

NotificationCompat.WearableExtender
setCustomSizePreset(sizePreset: Int)

Set the custom size preset for the display of this notification out of the available presets found in NotificationCompat.WearableExtender, e.

NotificationCompat.WearableExtender
setDismissalId(@Nullable dismissalId: String?)

Sets the dismissal id for this notification.

NotificationCompat.WearableExtender
setDisplayIntent(@Nullable intent: PendingIntent?)

Set an intent to launch inside of an activity view when displaying this notification.

NotificationCompat.WearableExtender
setGravity(gravity: Int)

Set the gravity that this notification should have within the available viewport space.

NotificationCompat.WearableExtender
setHintAmbientBigPicture(hintAmbientBigPicture: Boolean)

Set a hint that this notification's BigPictureStyle (if present) should be converted to low-bit and displayed in ambient mode, especially useful for barcodes and qr codes, as well as other simple black-and-white tickets.

NotificationCompat.WearableExtender
setHintAvoidBackgroundClipping(hintAvoidBackgroundClipping: Boolean)

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

NotificationCompat.WearableExtender
setHintContentIntentLaunchesActivity(hintContentIntentLaunchesActivity: Boolean)

Set a hint that this notification's content intent will launch an Activity directly, telling the platform that it can generate the appropriate transitions.

NotificationCompat.WearableExtender
setHintHideIcon(hintHideIcon: Boolean)

Set a hint that this notification's icon should not be displayed.

NotificationCompat.WearableExtender

Set a hint that the screen should remain on for at least this duration when this notification is displayed on the screen.

NotificationCompat.WearableExtender
setHintShowBackgroundOnly(hintShowBackgroundOnly: Boolean)

Set a visual hint that only the background image of this notification should be displayed, and other semantic content should be hidden.

NotificationCompat.WearableExtender
setStartScrollBottom(startScrollBottom: Boolean)

Set whether the scrolling position for the contents of this notification should start at the bottom of the contents instead of the top when the contents are too long to display within the screen.

Constants

SCREEN_TIMEOUT_LONG

static val SCREEN_TIMEOUT_LONG: Int

Deprecated: This feature is no longer supported.

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

Value: -1

SCREEN_TIMEOUT_SHORT

static val SCREEN_TIMEOUT_SHORT: Int

Deprecated: This feature is no longer supported.

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

Value: 0

SIZE_DEFAULT

static val SIZE_DEFAULT: Int

Deprecated: Display intents are no longer supported.

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

For custom display notifications created using setDisplayIntent, the default is SIZE_MEDIUM. All other notifications size automatically based on their content.

Value: 0

SIZE_FULL_SCREEN

static val SIZE_FULL_SCREEN: Int

Deprecated: Display intents are no longer supported.

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

This value is only applicable for custom display notifications created using setDisplayIntent.

Value: 5