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. |
MutableList<Notification!> |
getPages() 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 |
setContentIcon(icon: Int) 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 |
setCustomContentHeight(height: Int) 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 |
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 |
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 |
NotificationCompat.WearableExtender |
setHintHideIcon(hintHideIcon: Boolean) Set a hint that this notification's icon should not be displayed. |
NotificationCompat.WearableExtender |
setHintScreenTimeout(timeout: Int) 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 valSCREEN_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 valSCREEN_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 valSIZE_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 valSIZE_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