diff --git a/docs/html/wear/preview/features/notifications.jd b/docs/html/wear/preview/features/notifications.jd index 21a77c2907ebb..ff9da6aeece6a 100644 --- a/docs/html/wear/preview/features/notifications.jd +++ b/docs/html/wear/preview/features/notifications.jd @@ -1,7 +1,231 @@ -page.title=Expanded Notifications +page.title=Notification Changes in Android Wear 2.0 meta.tags="wear", "wear-preview", "notifications" page.tags="wear" +page.image=/wear/preview/images/expanded_diagram.png + @jd:body -

stub

\ No newline at end of file +
+
+ +

This document includes

+
    +
  1. Visual Updates
  2. +
  3. Expanded Notifications
  4. +
  5. MessagingStyle
  6. +
+
+
+ +

Android Wear 2.0 updates the visual style and interaction paradigm of notifications + as well as introduces expanded notifications, which provide substantial additional + content and actions in an app-like experience. +

+ +

The visual and interaction changes make it much easier for users to read and + interact with notifications from your application. Expanded notifications enable + you to deliver Wear users an app-like experience even if you haven't built an + Android Wear application. +

+ +

+ Note: When developing for Wear 2.0, ensure that + you have the latest version of the Android Wear app on your phone. +

+ +

Visual Updates

+

Notifications receive important visual updates in Wear 2.0, with + +material design visual changes. +

+ +

+

Figure 1. Comparison of the same notification in Android Wear 1.x and 2.0.

+ +

Some of the visual updates include:

+ +

Expanded Notifications

+

Android Wear 2.0 introduces expanded notifications, which provides + substantial additional content and actions for each notification. +

+

When you specify additional content pages + and actions for a notification, those are available to the user within the + expanded notification. Each expanded notification follows + Material Design for Android Wear, + so the user gets an app-like experience. +

+

+

Figure 2. An expanded notification with content and actions.

+

If the first action in the expanded notification has a +{@code RemoteInput} + (e.g., a Reply action), then the choices you set with {@code setChoices()} + appear within the expanded notification below the first action. +

+ +

The user can view the expanded notification by tapping on a notification when + either of the following is true: +

+ +

Best practices for expanded notifications

+

To decide when to use expanded notifications, follow these guidelines:

+ + +

Adding expanded notifications

+

+ Expanded Notifications allow you to include additional content and actions + for a notification. You choose the level of detail that your app's notifications + will provide; however be judicious with the amount of detail you include in a + notification. +

+

Adding additional content

+To show additional content in your expanded notification, see Adding Pages to a Notification.

+

Additional content pages are stacked vertically in the expanded notification + and appear in the order they were added. + These additional content pages can optionally use a style such as {@code BigTextStyle} or {@code BigPictureStyle}. +

+

Primary action

+The expanded notification will contain one primary action, which is the first +action in the notification unless a different action is specified using +{@code setContentAction()}. +

+

Additional actions

+

+ To specify additional actions, use + {@code addAction()} + or {@code addActions()}. + The action drawer of the expanded notification contains all available actions. +

+

MessagingStyle

+ +

If you have a chat messaging app, your notifications should use +{@code Notification.MessagingStyle}, + which is new in Android 6.0. Wear 2.0 uses the chat messages included + in a {@code MessagingStyle} notification + (see {@code addMessage()}) to provide + a rich chat app-like experience in the expanded notification. +

+

Note: {@code MessagingStyle} +expanded notifications require that you have at least version 1.5.0.2861804 of the + Android Wear application + on your paired Android phone. That version will be available within the next + few weeks in the Play Store. +

+

Smart Reply

+

Wear 2.0 also introduces Smart Reply for {@code MessagingStyle} notifications. + Smart Reply provides the user with contextually relevant, touchable choices in + the expanded notification and in {@code RemoteInput}. These augment the fixed + list of choices that the developer provides in + {@code RemoteInput} + using the + {@code setChoices()} method. +

+

By enabling Smart Reply for your MessagingStyle notifications, + you provide users with a fast (single tap), discreet (no speaking aloud), and + reliable way to respond to chat messages. +

+

+

Figure 3. The expanded notification includes contextually relevant + Smart Reply responses below the primary action. +

+ +

Responses generated by Smart Reply are shown in addition to those set using the + {@code setChoices()} method. +

+

To enable Smart Reply for your notification action, you need to do the +following: +

+
    +
  1. Use {@code Notification.MessagingStyle}. +
  2. +
  3. Call the method + {@code setAllowGeneratedReplies()} + for the notification action.
  4. +
  5. Ensure that the notification action has a + {@code RemoteInput} + (where the responses will reside). +
  6. +
+

The following example shows how to create a MessagingStyle notification with +Smart Reply responses.

+
+// Create an intent for the reply action
+Intent replyIntent = new Intent(this, ReplyActivity.class);
+PendingIntent replyPendingIntent =
+ PendingIntent.getActivity(this, 0, replyIntent,
+  PendingIntent.FLAG_UPDATE_CURRENT);
+
+// Create the reply action and add the remote input
+NotificationCompat.Action action =
+ new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,
+  getString(R.string.label), replyPendingIntent)
+ .addRemoteInput(remoteInput)
+
+// 1) allow generated replies
+.setAllowGeneratedReplies(true)
+ .build();
+
+Notification noti = new NotificationCompat.Builder()
+ .setContentTitle(messages.length + " new messages with " + sender.toString())
+ .setContentText(subject)
+ .setSmallIcon(R.drawable.new_message)
+ .setLargeIcon(aBitmap)
+ // 2) set the style to MessagingStyle
+ .setStyle(new NotificationCompat.MessagingStyle(resources.getString(R.string.reply_name)).addMessage(messages[0].getText(), messages[0].getTime(), messages[0].getSender())
+  .addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getSender()))
+
+
+// 3) add an action with RemoteInput
+.extend(new WearableExtender().addAction(action)).build();
+
diff --git a/docs/html/wear/preview/images/comparison_diagram.png b/docs/html/wear/preview/images/comparison_diagram.png new file mode 100644 index 0000000000000..7dbf65f2a216f Binary files /dev/null and b/docs/html/wear/preview/images/comparison_diagram.png differ diff --git a/docs/html/wear/preview/images/expanded_diagram.png b/docs/html/wear/preview/images/expanded_diagram.png new file mode 100644 index 0000000000000..3d1d00702f6fc Binary files /dev/null and b/docs/html/wear/preview/images/expanded_diagram.png differ diff --git a/docs/html/wear/preview/images/messaging_style.png b/docs/html/wear/preview/images/messaging_style.png new file mode 100644 index 0000000000000..966e524c6db52 Binary files /dev/null and b/docs/html/wear/preview/images/messaging_style.png differ diff --git a/docs/html/wear/preview/support.jd b/docs/html/wear/preview/support.jd new file mode 100644 index 0000000000000..d8a7ffb4be528 --- /dev/null +++ b/docs/html/wear/preview/support.jd @@ -0,0 +1,59 @@ +page.title=Support and Release Notes +meta.keywords="preview", "wear" +page.tags="preview", "developer preview" + +@jd:body + +

If you experience problems when developing and testing with + the Wear 2.0 Developer Preview, please file bugs at https://developer.android.com/wear/preview/bug + .

+ +

To discuss issues or ideas with other developers working with Android Wear, + join the + Wear Developer Google+ community. + +

Developer Preview 1

+ +
+
+
+

Date: May 2016
+ Builds: Wearable Support 2.0.0-alpha1, NVD36G
+ Emulator support: x86 & ARM (32-bit)
+

+
+
+
+ +

General advisories

+ +

This Developer Preview release is for app developers only and is designed + for use in compatibility testing and early development only.

+ +

Wear 2.0 Notifications

+ +

Notification groups

+ +

The current release of Android Wear 2.0 does not include support for notification + groups, also known as + stacks and bundles. You should continue to use notification groups because + that support will be coming in a future version of Android Wear 2.0.

+ +

Smart Reply

+ +

The current version of Wear 2.0 does not generate any Smart Reply responses + even if you call {@code setAllowGeneratedReplies()}. + This functionality will be added in a later version of Wear 2.0. +

+ +

Fields that are deprecated in Wear 2.0

+ + +