public static final class

WearableNotifications.Builder

extends Object
java.lang.Object
   ↳ android.preview.support.wearable.notifications.WearableNotifications.Builder

Class Overview

Builder object that wraps a NotificationCompat.Builder to provide methods for adding wearable extensions to a notification.

Methods on the wrapped NotificationCompat.Builder and this object can be called in any order, but the final Notification must be built with the build() method of this class.

Note: Notifications created using this builder should be posted to the notification system using the NotificationManagerCompat.notify(...) methods instead of NotificationManager.notify(...).

Example:

 NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
         .setContentTitle("New mail from " + sender.toString())
         .setContentText(subject)
         .setSmallIcon(R.drawable.new_mail);
 Notification notif = new WearableNotifications.Builder(builder)
         .setLocalOnly(true)
         .setMinPriority()
         .build();
 NotificationManagerCompat.from(mContext).notify(0, notif);

Summary

Public Constructors
WearableNotifications.Builder(Context context)
Construct a builder to be used for adding wearable extensions to notifications.
WearableNotifications.Builder(NotificationCompat.Builder builder)
Construct a builder to be used for adding wearable extensions to notifications to a NotificationCompat.Builder.
Public Methods
WearableNotifications.Builder addAction(WearableNotifications.Action action)
Add an action to this notification.
WearableNotifications.Builder addPage(Notification page)
Add an additional page of content to display with this notification.
WearableNotifications.Builder addPages(Collection<Notification> pages)
Add additional pages of content to display with this notification.
WearableNotifications.Builder addRemoteInputForContentIntent(RemoteInput input)
Adds a RemoteInput for the content intent.
Notification build()
Combine all of the options that have been set by both this builder and the wrapped NotificationCompat.Builder object and return a new Notification object.
NotificationCompat.Builder getCompatBuilder()
Return the NotificationCompat.Builder being wrapped by this object.
Bundle getExtras()
Get the current metadata Bundle used by this Builder, creating a new one as necessary.
WearableNotifications.Builder setBigActionIcon(int icon, CharSequence subtext)
Add a big action display to this notification.
WearableNotifications.Builder setBigActionIcon(int icon)
Add a big action display to this notification.
WearableNotifications.Builder setGroup(String groupKey, int groupOrder)
Set this notification to be part of a group of notifications sharing the same key.
WearableNotifications.Builder setGroup(String groupKey)
Set this notification to be part of a group of notifications sharing the same key.
WearableNotifications.Builder setHintHideIcon(boolean hintHideIcon)
Set a hint that this notification's icon should not be displayed.
WearableNotifications.Builder setLocalOnly(boolean localOnly)
Set whether or not this notification is only relevant to the current device.
WearableNotifications.Builder setMinPriority()
Set the priority of this notification to be minimum priority level (PRIORITY_MIN).
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public WearableNotifications.Builder (Context context)

Construct a builder to be used for adding wearable extensions to notifications. Both the wrapped builder (accessible via getCompatBuilder() and this builder can be used simultaneously, but the build() method from this object must be called in the end.

Note: Notifications created using this builder should be posted to the notification system using the NotificationManagerCompat.notify(...) methods instead of NotificationManager.notify(...).

Example:

 WearableNotifications.Builder builder = new WearableNotifications.Builder(mContext)
         .setLocalOnly(true);
 builder.getCompatBuilder()
         .setContentTitle("New mail from " + sender.toString())
         .setContentText(subject)
         .setSmallIcon(R.drawable.new_mail);
 Notification notif = builder.build();
 NotificationManagerCompat.from(mContext).notify(0, notif);

public WearableNotifications.Builder (NotificationCompat.Builder builder)

Construct a builder to be used for adding wearable extensions to notifications to a NotificationCompat.Builder. Both the wrapped builder and this builder can be used simultaneously, but the build() method from this object must be called in the end.

Note: Notifications created using this builder should be posted to the notification system using the NotificationManagerCompat.notify(...) methods instead of NotificationManager.notify(...).

Example:

 NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
         .setContentTitle("New mail from " + sender.toString())
         .setContentText(subject)
         .setSmallIcon(R.drawable.new_mail);
 Notification notif = new WearableNotifications.Builder(builder)
         .setLocalOnly(true)
         .build();
 NotificationManagerCompat.from(mContext).notify(0, notif);

Public Methods

public WearableNotifications.Builder addAction (WearableNotifications.Action action)

Add an action to this notification. Actions are typically displayed by the system as a button adjacent to the notification content. This method accepts WearableNotifications.Action extension wrappers. Actions added by this function are appended when build() is called.

public WearableNotifications.Builder addPage (Notification page)

Add an additional page of content to display with this notification. The current notification forms the first page, and pages added using this function form subsequent pages. This field can be used to separate a notification into multiple sections.

public WearableNotifications.Builder addPages (Collection<Notification> pages)

Add additional pages of content to display with this notification. The current notification forms the first page, and pages added using this function form subsequent pages. This field can be used to separate a notification into multiple sections.

public WearableNotifications.Builder addRemoteInputForContentIntent (RemoteInput input)

Adds a RemoteInput for the content intent. The collected data will be overlayed onto the content intent.

public Notification build ()

Combine all of the options that have been set by both this builder and the wrapped NotificationCompat.Builder object and return a new Notification object.

public NotificationCompat.Builder getCompatBuilder ()

Return the NotificationCompat.Builder being wrapped by this object.

public Bundle getExtras ()

Get the current metadata Bundle used by this Builder, creating a new one as necessary.

The returned Bundle is shared with this Builder.

public WearableNotifications.Builder setBigActionIcon (int icon, CharSequence subtext)

Add a big action display to this notification. Big actions show a hint to users about the action taken when the content intent is triggered.

Parameters
icon Icon to display for the content action.
subtext Optional subtext to display with the big action icon.

public WearableNotifications.Builder setBigActionIcon (int icon)

Add a big action display to this notification. Big actions show a hint to users about the action taken when the content intent is triggered.

Parameters
icon Icon to display for the content action.

public WearableNotifications.Builder setGroup (String groupKey, int groupOrder)

Set this notification to be part of a group of notifications sharing the same key. Grouped notifications may display in a cluster or stack on devices which support such rendering.

Parameters
groupKey The group key of the group. Unique within a package.
groupOrder The 0-indexed sort order within the group. Can also be set to the sentinel value GROUP_ORDER_SUMMARY to mark this notification as being the group summary.

public WearableNotifications.Builder setGroup (String groupKey)

Set this notification to be part of a group of notifications sharing the same key. Grouped notifications may display in a cluster or stack on devices which support such rendering. Use the default ordering within a group.

Parameters
groupKey The group key of the group. Unique within a package.

public WearableNotifications.Builder setHintHideIcon (boolean hintHideIcon)

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

public WearableNotifications.Builder setLocalOnly (boolean localOnly)

Set whether or not this notification is only relevant to the current device.

Some notifications can be bridged to other devices for remote display. This hint can be set to recommend this notification not be bridged.

public WearableNotifications.Builder setMinPriority ()

Set the priority of this notification to be minimum priority level (PRIORITY_MIN). When set via WearableNotifications, these minimum priority notifications will bypass the notification manager on platforms that do not support ambient level notifications.