diff --git a/docs/html/wear/design/index.html b/docs/html/wear/design/index.html deleted file mode 100644 index 53ea1f3e4f51a..0000000000000 --- a/docs/html/wear/design/index.html +++ /dev/null @@ -1,609 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Design Principles of Android Wear | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - -
- - - - - -

Design Principles of Android Wear

- - - - - - -
- - -
- -

-Android wearables provide just the right information at just the right time, allowing you to be connected to the virtual world and present in the real world.

- - - -

Here you’ll find some guidelines for designing great user experiences on the Android Wear -platform. Designing for Android Wear is substantially different than designing for phones or -tablets, so we’ll start by describing how your content can work in tandem with the overall -Android Wear vision. To better understand the user experience on Android Wear, also be sure -to read the UI Overview.

- - - - - - -

Android Wear experiences are:

- -
    -
  • Contextually aware and smart. These devices bring a new level of awareness to computing. Rather than requiring attention and input from users, Android wearables are aware of their situation and state, and helpfully display the right information at the right time. Timely, relevant, specific.
  • - -
  • Glanceable. Wearable devices are used all throughout the day, even when they sit in our peripheral vision. Effective apps provide the maximum payload of information with a minimum of fuss, optimized to provide tiny snippets of relevant information throughout the day. Short, sharp, immediate.
  • - -
  • Zero/low interaction. Staying true to the strengths afforded by a smaller form factor, Android Wear focuses on simple interactions, only requiring input by the user when absolutely necessary. Most inputs are based around touch swipes or voice, and inputs requiring fine-grained motor skills are avoided. Gestural, simple, fast.
  • - -
  • Helpful. Android Wear is like a great personal assistant: it knows you and your preferences, it only interrupts you when absolutely necessary, and it’s always on hand to provide a ready answer. Efficient, respectful, responsive.
  • -
- - -

-By providing a smart connection to the rest of the world while respecting the user’s attention, Android Wear feels personal and global, simple and smart, unobtrusive and ever-ready. Notifications that respect these principles will feel most at home in the overall Android Wear experience. -

- - - -

Notification UI Patterns

- -

Android notifications appear as cards in the main stream and form the core of the Android Wear experience. Many of the main Android Design guidelines for notifications apply in Android Wear. Be respectful of users' attention and aware of how unnecessary interruptions will reflect on your application’s reputation.

- -

Omit needless text from your notifications. Design for glanceability, not reading. Use words and phrases, not sentences. Show, don't tell: where possible use simple icons, glyphs, and visualizations to convey your message.

- - -

In some cases, particularly with messaging applications, cards will contain dynamic content which may not fit on a single screen. In these cases the content will be automatically truncated to fit on the card and the user may tap to expand, so the full message should be provided.

- -

Notification priority should reflect the urgency of your notification, with only time-sensitive notifications carrying a high priority. Active notifications – that is, those that cause the device to vibrate – should only be used in cases that need the user's urgent attention or action (e.g. a time-based reminder, a message from a friend). Non-urgent notifications (e.g. a transit times card, daily pedometer count, social network updates) should be silently added to the card stream.

- - - - -

Actions

- - - -

Actions appear to the right of your notification, allowing the user to act on your notification. Up to three actions are permitted. The most-used action should be placed first, so that it is a single swipe away from your content.

- -

Actions consist of an icon and a caption. Icons should be PNG files, white on transparent background, 32 × 32 dp (with 8 dp padding), as specified in the Iconography design guide -for the action bar icons. Captions should be verb-driven and short, and will be automatically truncated at one line.

- -

Actions are optional. Many useful notifications will not need to include actions at all.

- -

For developer details about action buttons, see Creating -Notifications for Android Wear.

- - - - - - -

Images

- - - - -

Images appear behind cards in the stream, providing context and additional glanceability. Your image should support the core message of the notification; for example, a card about a sports team could include the team color and logo; a message from a contact should display that person's profile photo.

- -

Bear in mind that the card will partially cover the lower part of the image. Images should be sized as -appropriate for the notification appearance on handsets, which is 64 x 64 dp. Image backgrounds move when horizontally swiped, so landscape-oriented images work better on notifications that include pages or actions.

- -

To add large images, use setLargeIcon() with any notification, as -shown in Creating -Notifications for Android Wear.

- - - - - -

Application Icons

- - - -

Your application’s launcher icon will be automatically placed on the card, identifying your notification. Do not use the notification title or background image to identify or brand your application. Instead, allow your icon to identify itself and focus on delivering a clear, succinct message in the card and image. You can choose not to display this icon using - setHintHideIcon(). -

- - - - - - - -

Pages

- -

Pages are additional cards that can appear to the right of your main card in the stream. If your core message is longer than a short snippet, do not sacrifice glanceability by packing a lot of information into your primary notification. Instead, use pages to provide additional content.

- - - - - -

Pages appear immediately to the right of the main notification card. They are typically used to provide additional details or alternate views of the main card’s content. For example:

-
    -
  • A current weather card might provide an additional page showing a three-day forecast.
  • -
  • A next train departure card might provide an additional page showing subsequent departures times.
  • -
  • A daily step count card might provide an additional page showing the same measurement in calories and distance.
  • -
- -

There is no imposed limit on the number of pages you may add. However, notifications that provide actions should show no more than three pages to ensure that the actions remain easily accessible.

- -

Pages are optional. Many useful notifications will not need to include pages at all.

- -

For developer details about pages, see -described in Adding -Pages to a Notification.

- - - - - -

Notification Stacks

- - - - -

Stacks may be used to collect multiple notifications from the same application into a single stack of cards. Whereas pages are used to provide additional detail on a single notification, stacks are used to collect multiple sibling notifications together. A stack may be expanded by the user to access each individual card contained within.

- -

Stacks are a way of adding multiple useful notifications without overwhelming the user’s stream. If your application may produce multiple concurrent notifications, consider combining them into a stack.

- -

Each notification within a stack can contain separate pages and separate actions that are relevant to that specific notification. The user can access these actions after expanding that notification's card within the stack.

- -

For developer details about stacks, see -described in Stacking -Notifications.

- - - - - - -

Voice Replies

- - - - - -

Voice replies are primarily used by messaging applications to provide a hands-free way of dictating a short message. You can also provide a up to five suggested replies or “canned responses” that are useful in a wide range of cases. These canned responses can be tapped by the user, allowing for a fast method of sending simple replies in cases where speaking may not be desirable.

- -

You should attempt to cover a range of simple, neutral replies in your choices. Longer voice replies may be automatically truncated in the Voice reply UI.

- -

For developer details about enabling voice replies, see -described in Receiving Voice Input from -a Notification.

- -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/design/index.jd b/docs/html/wear/design/index.jd new file mode 100644 index 0000000000000..247cc87434458 --- /dev/null +++ b/docs/html/wear/design/index.jd @@ -0,0 +1,173 @@ +page.title=Design Principles of Android Wear + +@jd:body + + +

+Android wearables provide just the right information at just the right time, allowing you to be connected to the virtual world and present in the real world.

+ + + +

Here you’ll find some guidelines for designing great user experiences on the Android Wear +platform. Designing for Android Wear is substantially different than designing for phones or +tablets, so we’ll start by describing how your content can work in tandem with the overall +Android Wear vision. To better understand the user experience on Android Wear, also be sure +to read the UI Overview.

+ + + + + + +

Android Wear experiences are:

+ + + + +

+By providing a smart connection to the rest of the world while respecting the user’s attention, Android Wear feels personal and global, simple and smart, unobtrusive and ever-ready. Notifications that respect these principles will feel most at home in the overall Android Wear experience. +

+ + + +

Notification UI Patterns

+ +

Android notifications appear as cards in the main stream and form the core of the Android Wear experience. Many of the main Android Design guidelines for notifications apply in Android Wear. Be respectful of users' attention and aware of how unnecessary interruptions will reflect on your application’s reputation.

+ +

Omit needless text from your notifications. Design for glanceability, not reading. Use words and phrases, not sentences. Show, don't tell: where possible use simple icons, glyphs, and visualizations to convey your message.

+ + +

In some cases, particularly with messaging applications, cards will contain dynamic content which may not fit on a single screen. In these cases the content will be automatically truncated to fit on the card and the user may tap to expand, so the full message should be provided.

+ +

Notification priority should reflect the urgency of your notification, with only time-sensitive notifications carrying a high priority. Active notifications – that is, those that cause the device to vibrate – should only be used in cases that need the user's urgent attention or action (e.g. a time-based reminder, a message from a friend). Non-urgent notifications (e.g. a transit times card, daily pedometer count, social network updates) should be silently added to the card stream.

+ + + + +

Actions

+ + + +

Actions appear to the right of your notification, allowing the user to act on your notification. Up to three actions are permitted. The most-used action should be placed first, so that it is a single swipe away from your content.

+ +

Actions consist of an icon and a caption. Icons should be PNG files, white on transparent +background, 32 × 32 dp (with 8 dp padding), as specified in the Iconography design guide for action bar +icons. Captions should be verb-driven and short, and will be automatically truncated at one line. +

+ +

Actions are optional. Many useful notifications will not need to include actions at all.

+ +

For developer details about action buttons, see Creating +Notifications for Android Wear.

+ + + + + + +

Images

+ + + + +

Images appear behind cards in the stream, providing context and additional glanceability. Your image should support the core message of the notification; for example, a card about a sports team could include the team color and logo; a message from a contact should display that person's profile photo.

+ +

Bear in mind that the card will partially cover the lower part of the image. Images should +be sized as appropriate for the notification appearance on handsets, which is 64 x 64 dp. Image backgrounds move when horizontally swiped, so landscape-oriented images work better on notifications that include pages or actions.

+ +

To add large images, use {@link android.support.v4.app.NotificationCompat.Builder#setLargeIcon +setLargeIcon()} with any notification, as +shown in Creating +Notifications for Android Wear.

+ + + + + +

Application Icons

+ + + +

Your application’s launcher icon will be automatically placed on the card, identifying your notification. Do not use the notification title or background image to identify or brand your application. Instead, allow your icon to identify itself and focus on delivering a clear, succinct message in the card and image. You can choose not to display this icon using + setHintHideIcon(). +

+ + + + + + + +

Pages

+ +

Pages are additional cards that can appear to the right of your main card in the stream. If your core message is longer than a short snippet, do not sacrifice glanceability by packing a lot of information into your primary notification. Instead, use pages to provide additional content.

+ + + + + +

Pages appear immediately to the right of the main notification card. They are typically used to provide additional details or alternate views of the main card’s content. For example:

+ + +

There is no imposed limit on the number of pages you may add. However, notifications that provide actions should show no more than three pages to ensure that the actions remain easily accessible.

+ +

Pages are optional. Many useful notifications will not need to include pages at all.

+ +

For developer details about pages, see +described in Adding +Pages to a Notification.

+ + + + + +

Notification Stacks

+ + + + +

Stacks may be used to collect multiple notifications from the same application into a single stack of cards. Whereas pages are used to provide additional detail on a single notification, stacks are used to collect multiple sibling notifications together. A stack may be expanded by the user to access each individual card contained within.

+ +

Stacks are a way of adding multiple useful notifications without overwhelming the user’s stream. If your application may produce multiple concurrent notifications, consider combining them into a stack.

+ +

Each notification within a stack can contain separate pages and separate actions that are relevant to that specific notification. The user can access these actions after expanding that notification's card within the stack.

+ +

For developer details about stacks, see +described in Stacking +Notifications.

+ + + + + + +

Voice Replies

+ + + + + +

Voice replies are primarily used by messaging applications to provide a hands-free way of dictating a short message. You can also provide a up to five suggested replies or “canned responses” that are useful in a wide range of cases. These canned responses can be tapped by the user, allowing for a fast method of sending simple replies in cases where speaking may not be desirable.

+ +

You should attempt to cover a range of simple, neutral replies in your choices. Longer voice replies may be automatically truncated in the Voice reply UI.

+ +

For developer details about enabling voice replies, see +described in Receiving Voice Input from +a Notification.

diff --git a/docs/html/wear/design/user-interface.html b/docs/html/wear/design/user-interface.html deleted file mode 100644 index c23d79cf4ff1c..0000000000000 --- a/docs/html/wear/design/user-interface.html +++ /dev/null @@ -1,498 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -UI Overview | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - -
- - - - - -

UI Overview

- - - - - - -
- - -
- - -

A new form factor deserves a new UI model. At a high level, the Android Wear UI consists of two -main spaces centered around the core functions of Suggest and -Demand. Your application will have an important role to play in both of these -spaces.

- - - -

Suggest: The Context Stream

- -
- - -
- -

The context stream is a vertical list of cards, each showing a useful or timely piece of -information. Much like Google Now on Android phones and tablets, users swipe vertically to navigate -from card to card for a brief and comprehensive update about what's important to them. Only one card -is displayed on screen at a time, and background images are used to provide additional visual -information. Your application can create cards and inject them into the stream when they are most -likely to be useful.

- -

Cards in the stream are more than simple notifications. They can be swiped horizontally to -reveal additional pages. Further horizontal swiping may reveal tappable buttons, allowing the user -to take action on the notification. Cards can also be dismissed by swiping left to right, removing -them from the stream until the next time they have useful information to display. -In the emulator, hovering the mouse over the top of the screen illuminates a blue bar at -the top of the device that takes you home when clicked.

- - - -

Demand: The Cue Card

- -
- - -
- -

For cases where the context stream can't anticipate what the user would like to do, the cue card -allows users to speak to their device. The cue card is opened by saying, "Ok Google" or by tapping -on the "g" icon on the home screen. Swiping up on the cue card shows a list of actions, which can -also be tapped.

- -

The list of actions includes Android intents for voice actions. The upcoming Android Wear SDK -will enable developers to match their applications to these intents so users can perform actions -using these voice commands. Multiple applications may register for a single voice intent, and users -will have the opportunity to choose which application they prefer to use.

- - -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/design/user-interface.jd b/docs/html/wear/design/user-interface.jd new file mode 100644 index 0000000000000..2a3e9ef3a76c7 --- /dev/null +++ b/docs/html/wear/design/user-interface.jd @@ -0,0 +1,58 @@ +page.title=UI Overview +page.customHeadTag= + +@jd:body + + + +

A new form factor deserves a new UI model. At a high level, the Android Wear UI consists of two +main spaces centered around the core functions of Suggest and +Demand. Your application will have an important role to play in both of these +spaces.

+ + + +

Suggest: The Context Stream

+ +
+ + +
+ +

The context stream is a vertical list of cards, each showing a useful or timely piece of +information. Much like Google Now on Android phones and tablets, users swipe vertically to navigate +from card to card for a brief and comprehensive update about what's important to them. Only one card +is displayed on screen at a time, and background images are used to provide additional visual +information. Your application can create cards and inject them into the stream when they are most +likely to be useful.

+ +

Cards in the stream are more than simple notifications. They can be swiped horizontally to +reveal additional pages. Further horizontal swiping may reveal tappable buttons, allowing the user +to take action on the notification. Cards can also be dismissed by swiping left to right, removing +them from the stream until the next time they have useful information to display. +In the emulator, hovering the mouse over the top of the screen illuminates a blue bar at +the top of the device that takes you home when clicked.

+ + + +

Demand: The Cue Card

+ +
+ + +
+ +

For cases where the context stream can't anticipate what the user would like to do, the cue card +allows users to speak to their device. The cue card is opened by saying, "Ok Google" or by tapping +on the "g" icon on the home screen. Swiping up on the cue card shows a list of actions, which can +also be tapped.

+ +

The list of actions includes Android intents for voice actions. The upcoming Android Wear SDK +will enable developers to match their applications to these intents so users can perform actions +using these voice commands. Multiple applications may register for a single voice intent, and users +will have the opportunity to choose which application they prefer to use.

+ diff --git a/docs/html/wear/index.html b/docs/html/wear/index.jd similarity index 67% rename from docs/html/wear/index.html rename to docs/html/wear/index.jd index 966046330441b..b977554a374c4 100644 --- a/docs/html/wear/index.html +++ b/docs/html/wear/index.jd @@ -1,286 +1,12 @@ - +page.title=Android Wear +page.viewport-width=970 +fullpage=true +no_footer_links=true +page.customHeadTag= +@jd:body - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Android Wear | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - - - -
- - -
- -
- -
- - - -
- - - - -
- - -
- - - - - - - - - - - - - - - - - diff --git a/docs/html/wear/license.html b/docs/html/wear/license.jd similarity index 63% rename from docs/html/wear/license.html rename to docs/html/wear/license.jd index c7569bce3ae9d..b07dacfac0559 100644 --- a/docs/html/wear/license.html +++ b/docs/html/wear/license.jd @@ -1,379 +1,9 @@ - +page.title=Developer Preview License Agreement +@jd:body - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Developer Preview License Agreement | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - -
- - - - - -

Developer Preview License Agreement

- - - - - - -
- - -
-
+
This is the Android Wear Developer Preview License Agreement. 1. Introduction @@ -510,72 +140,3 @@ This is the Android Wear Developer Preview License Agreement. 14.7 This License Agreement, and your relationship with Google under this License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from this License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
- -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/notifications/creating.html b/docs/html/wear/notifications/creating.html deleted file mode 100644 index 7ad6833e3c7db..0000000000000 --- a/docs/html/wear/notifications/creating.html +++ /dev/null @@ -1,722 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Creating Notifications for Android Wear | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - -

Creating Notifications for Android Wear

- - - - - - -
- - -
-

When an Android device such as a phone or tablet is connected to an Android wearable, -all notifications are shared between the devices by default. On the Android wearable, each -notification appears as a new card in the context stream.

- - - - -

So without any effort, your app notifications are available to users on Android Wear. -However, you can enhance the user experience in several ways. For instance, -if users may respond to a notification by entering text, such as to reply to -a message, you can add the ability for users to reply by voice directly from the -wearable.

- -

To help you provide the best user experience -for your notifications on Android Wear, this guide shows you how to -build notifications using standard templates in -the NotificationCompat.Builder APIs, plus how to begin -extending your notification's capabilities for the wearable user experience.

- -

Note: -Notifications using RemoteViews are stripped of custom -layouts and the system uses only the text and icons in the -Notification object to -display the notification in a card. However, custom card layouts will be supported by -the official Android Wear SDK that is coming later.

-
- - - - -

Import the Necessary Classes

- -

To begin development, you must first complete the instructions in the Get Started with the Developer Preview document. -As mentioned in that document, your app must include -both the v4 support -library and the Developer Preview support library. So to get started, -you should include the following imports in your project code:

- -
-import android.preview.support.wearable.notifications.*;
-import android.preview.support.v4.app.NotificationManagerCompat;
-import android.support.v4.app.NotificationCompat;
-
- -

Caution: -The APIs in the current Android Wear Developer Preview are intended for development and testing purposes only, not for production apps. Google may change this Developer Preview significantly prior to the official release of the Android Wear SDK. You may not publicly distribute or ship any application using this Developer Preview, as this Developer Preview will no longer be supported after the official SDK is released (which will cause applications based only on the Developer Preview to break).

- - - -

Create Notifications with the Notification Builder

- -

The v4 -support library allows you to create notifications using the latest notification features -such as action buttons and large icons, while remaining compatible with Android 1.6 (API level -4) and higher.

- - -

For example, here's some code that creates and issues a notification using the -NotificationCompat APIs combined with the new - -NotificationManagerCompat API:

- - -
-int notificationId = 001;
-// Build intent for notification content
-Intent viewIntent = new Intent(this, ViewEventActivity.class);
-viewIntent.putExtra(EXTRA_EVENT_ID, eventId);
-PendingIntent viewPendingIntent =
-        PendingIntent.getActivity(this, 0, viewIntent, 0);
-
-NotificationCompat.Builder notificationBuilder =
-        new NotificationCompat.Builder(this)
-        .setSmallIcon(R.drawable.ic_event)
-        .setContentTitle(eventTitle)
-        .setContentText(eventLocation)
-        .setContentIntent(viewPendingIntent);
-
-// Get an instance of the NotificationManager service
-NotificationManagerCompat notificationManager =
-        NotificationManagerCompat.from(this);
-
-// Build the notification and issues it with notification manager.
-notificationManager.notify(notificationId, notificationBuilder.build());
-
- -

When this notification appears on a handheld device, the user can invoke the -PendingIntent -specified by the setContentIntent() method by touching the notification. When this -notification appears on an Android wearable, the user can swipe the notification to the left to -reveal the Open action, which invokes the intent on the handheld device.

- - - - - - - - -

Add Action Buttons

- -

In addition to the primary content action defined by -setContentIntent(), you can add other actions by passing a PendingIntent to -the addAction() method.

- -

For example, the following code shows the same type of notification from above, but adds an -action to view the event location on a map.

- -
-// Build an intent for an action to view a map
-Intent mapIntent = new Intent(Intent.ACTION_VIEW);
-Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));
-mapIntent.setData(geoUri);
-PendingIntent mapPendingIntent =
-        PendingIntent.getActivity(this, 0, mapIntent, 0);
-
-NotificationCompat.Builder notificationBuilder =
-        new NotificationCompat.Builder(this)
-        .setSmallIcon(R.drawable.ic_event)
-        .setContentTitle(eventTitle)
-        .setContentText(eventLocation)
-        .setContentIntent(viewPendingIntent)
-        .addAction(R.drawable.ic_map,
-                getString(R.string.map), mapPendingIntent);
-
- -

On a handheld device, the action appears as an -additional button attached to the notification. On an Android wearable, the action appears as -a large button when the user swipes the notification to the left. When the user taps the action, -the associated Intent is invoked on the handheld device.

- -

Tip: If your notifications includes a "Reply" action - (such as for a messaging app), you can enhance the behavior by enabling - voice input replies directly from the Android wearable. For more information, read - Receiving Voice Input from a Notification. -

- -

For details about designing action buttons (including the icon specifications), see the -Design Principles of Android -Wear.

- - -

Add a Big View

- - - -

You can insert extended text content -to your notification by adding one of the "big view" styles to your notification. On a -handheld device, users can see the big view content by expanding the notification, -while on Android Wear, the big view content is visible by default.

- -

To add the extended content to your notification, call setStyle() on the NotificationCompat.Builder object, passing it an instance of either -BigTextStyle or -InboxStyle.

- -

For example, the following code adds an instance of -NotificationCompat.BigTextStyle to the event notification, -in order to include the complete event description (which includes more text than can fit -into the space provided for setContentText()).

- - -
-// Specify the 'big view' content to display the long
-// event description that may not fit the normal content text.
-BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
-bigStyle.bigText(eventDescription);
-
-NotificationCompat.Builder notificationBuilder =
-        new NotificationCompat.Builder(this)
-        .setSmallIcon(R.drawable.ic_event)
-        .setLargeIcon(BitmapFractory.decodeResource(
-                getResources(), R.drawable.notif_background))
-        .setContentTitle(eventTitle)
-        .setContentText(eventLocation)
-        .setContentIntent(viewPendingIntent)
-        .addAction(R.drawable.ic_map,
-                getString(R.string.map), mapPendingIntent)
-        .setStyle(bigStyle);
-
- -

Notice that you can add a large background image to any notification using the -setLargeIcon() -method. For more information about designing notifications with large images, see the -Design Principles of Android -Wear.

- - - -

Add New Features for Wearables

- -

The Android Wear preview support library provides new APIs that - allow you to enhance the user experience for notifications on a wearable device. For example, - you can add additional pages of content that users can view by swiping to the left, or add the ability -for users to deliver your app a text response using voice input.

- -

To use these new APIs, pass your instance of -NotificationCompat.Builder to the - WearableNotifications.Builder() constructor. You can then add new -features to your notification using the - WearableNotifications.Builder methods. For example:

- -
-// Create a NotificationCompat.Builder for standard notification features
-NotificationCompat.Builder notificationBuilder =
-        new NotificationCompat.Builder(mContext)
-        .setContentTitle("New mail from " + sender.toString())
-        .setContentText(subject)
-        .setSmallIcon(R.drawable.new_mail);
-
-// Create a WearablesNotification.Builder to add special functionality for wearables
-Notification notification =
-        new WearableNotifications.Builder(notificationBuilder)
-        .setHintHideIcon(true)
-        .build();
-
- -

The - setHintHideIcon() method removes your app icon from the notification card. - This method is just one example of new notification features available from the - WearableNotifications.Builder class.

- -

When you want to deliver your notifications, be certain to always use the - - NotificationManagerCompat API:

- -
-// Get an instance of the NotificationManager service
-NotificationManagerCompat notificationManager =
-        NotificationManagerCompat.from(this);
-
-// Build the notification and issues it with notification manager.
-notificationManager.notify(notificationId, notification);
-
- -

If you instead use the framework's NotificationManager, some -features from WearableNotifications.Builder -will not work.

- -

To continue enhancing your notifications for wearables using - WearableNotifications.Builder and other APIs in the - preview support library, see the following developer guides:

- -
-
Receiving Voice Input -from a Notification
-
Add an action that receives voice input from the user and delivers the -transcribed message to your app.
-
Adding Pages to a Notification
-
Add additional pages of information that are visible when the user -swipes to the left.
-
Stacking Notifications
-
Place all similar notifications from your app in a stack, allowing each to be -viewed individually without adding multiple cards to the card stream.
-
- - -
- -
-

You might also want to read:

-
-
Notifying the User
-
Learn more about how to create notifications.
-
Intents and Intent Filters
-
Learn everything you need to know about the Intent -APIs, used by notificaton actions.
-
-
-
- - - - - -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/notifications/creating.jd b/docs/html/wear/notifications/creating.jd new file mode 100644 index 0000000000000..133d057144422 --- /dev/null +++ b/docs/html/wear/notifications/creating.jd @@ -0,0 +1,289 @@ +page.title=Creating Notifications for Android Wear + +@jd:body + + +

When an Android device such as a phone or tablet is connected to an Android wearable, +all notifications are shared between the devices by default. On the Android wearable, each +notification appears as a new card in the context stream.

+ + + + +

So without any effort, your app notifications are available to users on Android Wear. +However, you can enhance the user experience in several ways. For instance, +if users may respond to a notification by entering text, such as to reply to +a message, you can add the ability for users to reply by voice directly from the +wearable.

+ +

To help you provide the best user experience +for your notifications on Android Wear, this guide shows you how to +build notifications using standard templates in +the {@link android.support.v4.app.NotificationCompat.Builder} APIs, plus how to begin +extending your notification's capabilities for the wearable user experience.

+ +

Note: +Notifications using {@link android.widget.RemoteViews} are stripped of custom +layouts and the system uses only the text and icons in the +{@link android.app.Notification} object to +display the notification in a card. However, custom card layouts will be supported by +the official Android Wear SDK that is coming later.

+ + + + + +

Import the Necessary Classes

+ +

To begin development, you must first complete the instructions in the Get Started with the Developer Preview document. +As mentioned in that document, your app must include +both the v4 support +library and the Developer Preview support library. So to get started, +you should include the following imports in your project code:

+ +
+import android.preview.support.wearable.notifications.*;
+import android.preview.support.v4.app.NotificationManagerCompat;
+import android.support.v4.app.NotificationCompat;
+
+ +

Caution: +The APIs in the current Android Wear Developer Preview are intended for development and testing purposes only, not for production apps. Google may change this Developer Preview significantly prior to the official release of the Android Wear SDK. You may not publicly distribute or ship any application using this Developer Preview, as this Developer Preview will no longer be supported after the official SDK is released (which will cause applications based only on the Developer Preview to break).

+ + + +

Create Notifications with the Notification Builder

+ +

The v4 +support library allows you to create notifications using the latest notification features +such as action buttons and large icons, while remaining compatible with Android 1.6 (API level +4) and higher.

+ + +

For example, here's some code that creates and issues a notification using the +{@link android.support.v4.app.NotificationCompat} APIs combined with the new + +NotificationManagerCompat API:

+ + +
+int notificationId = 001;
+// Build intent for notification content
+Intent viewIntent = new Intent(this, ViewEventActivity.class);
+viewIntent.putExtra(EXTRA_EVENT_ID, eventId);
+PendingIntent viewPendingIntent =
+        PendingIntent.getActivity(this, 0, viewIntent, 0);
+
+NotificationCompat.Builder notificationBuilder =
+        new NotificationCompat.Builder(this)
+        .setSmallIcon(R.drawable.ic_event)
+        .setContentTitle(eventTitle)
+        .setContentText(eventLocation)
+        .setContentIntent(viewPendingIntent);
+
+// Get an instance of the NotificationManager service
+NotificationManagerCompat notificationManager =
+        NotificationManagerCompat.from(this);
+
+// Build the notification and issues it with notification manager.
+notificationManager.notify(notificationId, notificationBuilder.build());
+
+ +

When this notification appears on a handheld device, the user can invoke the +{@link android.app.PendingIntent} +specified by the {@link android.support.v4.app.NotificationCompat.Builder#setContentIntent +setContentIntent()} method by touching the notification. When this +notification appears on an Android wearable, the user can swipe the notification to the left to +reveal the Open action, which invokes the intent on the handheld device.

+ + + + + + + + +

Add Action Buttons

+ +

In addition to the primary content action defined by +{@link android.support.v4.app.NotificationCompat.Builder#setContentIntent +setContentIntent()}, you can add other actions by passing a {@link android.app.PendingIntent} to +the {@link android.support.v4.app.NotificationCompat.Builder#addAction +addAction()} method.

+ +

For example, the following code shows the same type of notification from above, but adds an +action to view the event location on a map.

+ +
+// Build an intent for an action to view a map
+Intent mapIntent = new Intent(Intent.ACTION_VIEW);
+Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));
+mapIntent.setData(geoUri);
+PendingIntent mapPendingIntent =
+        PendingIntent.getActivity(this, 0, mapIntent, 0);
+
+NotificationCompat.Builder notificationBuilder =
+        new NotificationCompat.Builder(this)
+        .setSmallIcon(R.drawable.ic_event)
+        .setContentTitle(eventTitle)
+        .setContentText(eventLocation)
+        .setContentIntent(viewPendingIntent)
+        .addAction(R.drawable.ic_map,
+                getString(R.string.map), mapPendingIntent);
+
+ +

On a handheld device, the action appears as an +additional button attached to the notification. On an Android wearable, the action appears as +a large button when the user swipes the notification to the left. When the user taps the action, +the associated {@link android.content.Intent} is invoked on the handheld device.

+ +

Tip: If your notifications includes a "Reply" action + (such as for a messaging app), you can enhance the behavior by enabling + voice input replies directly from the Android wearable. For more information, read + Receiving Voice Input from a Notification. +

+ +

For details about designing action buttons (including the icon specifications), see the +Design Principles of Android +Wear.

+ + +

Add a Big View

+ + + +

You can insert extended text content +to your notification by adding one of the "big view" styles to your notification. On a +handheld device, users can see the big view content by expanding the notification, +while on Android Wear, the big view content is visible by default.

+ +

To add the extended content to your notification, call {@link +android.support.v4.app.NotificationCompat.Builder#setStyle setStyle()} on the {@link +android.support.v4.app.NotificationCompat.Builder} object, passing it an instance of either +{@link android.support.v4.app.NotificationCompat.BigTextStyle BigTextStyle} or +{@link android.support.v4.app.NotificationCompat.InboxStyle InboxStyle}.

+ +

For example, the following code adds an instance of +{@link android.support.v4.app.NotificationCompat.BigTextStyle} to the event notification, +in order to include the complete event description (which includes more text than can fit +into the space provided for {@link android.support.v4.app.NotificationCompat.Builder#setContentText +setContentText()}).

+ + +
+// Specify the 'big view' content to display the long
+// event description that may not fit the normal content text.
+BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
+bigStyle.bigText(eventDescription);
+
+NotificationCompat.Builder notificationBuilder =
+        new NotificationCompat.Builder(this)
+        .setSmallIcon(R.drawable.ic_event)
+        .setLargeIcon(BitmapFractory.decodeResource(
+                getResources(), R.drawable.notif_background))
+        .setContentTitle(eventTitle)
+        .setContentText(eventLocation)
+        .setContentIntent(viewPendingIntent)
+        .addAction(R.drawable.ic_map,
+                getString(R.string.map), mapPendingIntent)
+        .setStyle(bigStyle);
+
+ +

Notice that you can add a large background image to any notification using the +{@link android.support.v4.app.NotificationCompat.Builder#setLargeIcon setLargeIcon()} +method. For more information about designing notifications with large images, see the +Design Principles of Android +Wear.

+ + + +

Add New Features for Wearables

+ +

The Android Wear preview support library provides new APIs that + allow you to enhance the user experience for notifications on a wearable device. For example, + you can add additional pages of content that users can view by swiping to the left, or add the ability +for users to deliver your app a text response using voice input.

+ +

To use these new APIs, pass your instance of +{@link android.support.v4.app.NotificationCompat.Builder} to the + WearableNotifications.Builder() constructor. You can then add new +features to your notification using the + WearableNotifications.Builder methods. For example:

+ +
+// Create a NotificationCompat.Builder for standard notification features
+NotificationCompat.Builder notificationBuilder =
+        new NotificationCompat.Builder(mContext)
+        .setContentTitle("New mail from " + sender.toString())
+        .setContentText(subject)
+        .setSmallIcon(R.drawable.new_mail);
+
+// Create a WearablesNotification.Builder to add special functionality for wearables
+Notification notification =
+        new WearableNotifications.Builder(notificationBuilder)
+        .setHintHideIcon(true)
+        .build();
+
+ +

The + setHintHideIcon() method removes your app icon from the notification card. + This method is just one example of new notification features available from the + WearableNotifications.Builder class.

+ +

When you want to deliver your notifications, be certain to always use the + + NotificationManagerCompat API:

+ +
+// Get an instance of the NotificationManager service
+NotificationManagerCompat notificationManager =
+        NotificationManagerCompat.from(this);
+
+// Build the notification and issues it with notification manager.
+notificationManager.notify(notificationId, notification);
+
+ +

If you instead use the framework's {@link android.app.NotificationManager}, some +features from WearableNotifications.Builder +will not work.

+ +

To continue enhancing your notifications for wearables using + WearableNotifications.Builder and other APIs in the + preview support library, see the following developer guides:

+ +
+
Receiving Voice Input +from a Notification
+
Add an action that receives voice input from the user and delivers the +transcribed message to your app.
+
Adding Pages to a Notification
+
Add additional pages of information that are visible when the user +swipes to the left.
+
Stacking Notifications
+
Place all similar notifications from your app in a stack, allowing each to be +viewed individually without adding multiple cards to the card stream.
+
+ + +
+ +
+

You might also want to read:

+
+
Notifying the User
+
Learn more about how to create notifications.
+
Intents and Intent Filters
+
Learn everything you need to know about the {@link android.content.Intent} +APIs, used by notificaton actions.
+
+
+
+ + + + diff --git a/docs/html/wear/notifications/pages.html b/docs/html/wear/notifications/pages.html deleted file mode 100644 index ce568ebd7e1da..0000000000000 --- a/docs/html/wear/notifications/pages.html +++ /dev/null @@ -1,500 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Adding Pages to a Notification | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - -
- - - - - -

Adding Pages to a Notification

- - - - - - -
- - -
- - - -

When you'd like to provide more information without requiring users -to open your app on their handheld device, you can -add one or more pages to the notification on Android Wear. The additional pages -appear immediately to the right of the main notification card. -For information about when to use and how to design -multiple pages, see the -Design Principles of Android -Wear.

- - -

When creating a notification with multiple pages, start by creating the main notification -(the first page) the way you'd like the notification to appear on a phone -or tablet. Then, add pages one at a time with the - -addPage() method, or add multiple pages in a Collection with the - -addPages() method.

- - -

For example, here's some code that adds a second page to a notification:

- -
-// Create builder for the main notification
-NotificationCompat.Builder notificationBuilder =
-        new NotificationCompat.Builder(this)
-        .setSmallIcon(R.drawable.new_message)
-        .setContentTitle("Page 1")
-        .setContentText("Short message")
-        .setContentIntent(viewPendingIntent);
-
-// Create a big text style for the second page
-BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
-secondPageStyle.setBigContentTitle("Page 2")
-               .bigText("A lot of text...");
-
-// Create second page notification
-Notification secondPageNotification =
-        new NotificationCompat.Builder(this)
-        .setStyle(secondPageStyle)
-        .build();
-
-// Create main notification and add the second page
-Notification twoPageNotification =
-        new WearableNotifications.Builder(notificationBuilder)
-        .addPage(secondPageNotification)
-        .build();
-
- - - - - - - -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/notifications/pages.jd b/docs/html/wear/notifications/pages.jd new file mode 100644 index 0000000000000..558f7b8e89826 --- /dev/null +++ b/docs/html/wear/notifications/pages.jd @@ -0,0 +1,61 @@ +page.title=Adding Pages to a Notification + +@jd:body + + + + + +

When you'd like to provide more information without requiring users +to open your app on their handheld device, you can +add one or more pages to the notification on Android Wear. The additional pages +appear immediately to the right of the main notification card. +For information about when to use and how to design +multiple pages, see the +Design Principles of Android +Wear.

+ + +

When creating a notification with multiple pages, start by creating the main notification +(the first page) the way you'd like the notification to appear on a phone +or tablet. Then, add pages one at a time with the + +addPage() method, or add multiple pages in a {@link java.util.Collection} with the + +addPages() method.

+ + +

For example, here's some code that adds a second page to a notification:

+ +
+// Create builder for the main notification
+NotificationCompat.Builder notificationBuilder =
+        new NotificationCompat.Builder(this)
+        .setSmallIcon(R.drawable.new_message)
+        .setContentTitle("Page 1")
+        .setContentText("Short message")
+        .setContentIntent(viewPendingIntent);
+
+// Create a big text style for the second page
+BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
+secondPageStyle.setBigContentTitle("Page 2")
+               .bigText("A lot of text...");
+
+// Create second page notification
+Notification secondPageNotification =
+        new NotificationCompat.Builder(this)
+        .setStyle(secondPageStyle)
+        .build();
+
+// Create main notification and add the second page
+Notification twoPageNotification =
+        new WearableNotifications.Builder(notificationBuilder)
+        .addPage(secondPageNotification)
+        .build();
+
+ + + + + + diff --git a/docs/html/wear/notifications/remote-input.html b/docs/html/wear/notifications/remote-input.html deleted file mode 100644 index 3d869b5c6ff2b..0000000000000 --- a/docs/html/wear/notifications/remote-input.html +++ /dev/null @@ -1,652 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Receiving Voice Input from a Notification | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - -
- - - - - -

Receiving Voice Input from a Notification

- - - - - - -
- - -
- - - - -

If your notification includes an action to respond with text, - such as to reply to an email, it should normally launch an activity - on the handheld device. However, when your notification appears on an Android wearable, you can - allow users to dictate a reply with voice input. You can also provide pre-defined text - messages for the user to select.

- -

When the user replies with voice or selects one of the available -messages, the system sends the message to your app on the connected handheld device. -The message is attached as an extra in the Intent you specified -to be used for the notification action.

- -

Note: When developing with the Android emulator, -you must type text replies into the voice input field, so be sure you have enabled -Hardware keyboard present in the AVD settings.

- - -

Define the Remote Input

- -

To create an action that supports voice input, first create an instance of - -RemoteInput using the - RemoteInput.Builder APIs. - The - RemoteInput.Builder constructor takes a string that the system - will use as a key for the Intent extra that carries the reply message - to your app on the handheld.

- -

For example, here's how to create a new - -RemoteInput object that provides a custom - label for the voice input prompt:

- -
-// Key for the string that's delivered in the action's intent
-private static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
-
-String replyLabel = getResources().getString(R.string.reply_label);
-
-RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
-        .setLabel(replyLabel)
-        .build();
-
- - -

Add Pre-defined Text Responses

- - - -

In addition to allowing voice input, you can - provide up to five text responses that the user can select for quick replies. Call - setChoices() and pass it a string array.

- -

For example, you may define some responses in a resource array:

- -

res/values/strings.xml -

-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-    <string-array name="reply_choices">
-        <item>Yes</item>
-        <item>No</item>
-        <item>Maybe</item>
-    </string-array>
-</resources>
-
- -

Then, inflate the string array and add it to the - RemoteInput:

- -
-String replyLabel = getResources().getString(R.string.reply_label);
-String[] replyChoices = getResources().getStringArray(R.array.reply_choices);
-
-RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
-        .setLabel(replyLabel)
-        .setChoices(replyChoices)
-        .build();
-
- - - - -

Receive Voice Input for the Primary Action

- -

If "Reply" is your notification's primary action (defined by the setContentIntent() -method), then you should attach the - RemoteInput to the main action using - -addRemoteInputForContentIntent(). For example:

- -
-// Create intent for reply action
-Intent replyIntent = new Intent(this, ReplyActivity.class);
-PendingIntent replyPendingIntent =
-        PendingIntent.getActivity(this, 0, replyIntent, 0);
-
-// Build the notification
-NotificationCompat.Builder replyNotificationBuilder =
-        new NotificationCompat.Builder(this)
-        .setSmallIcon(R.drawable.ic_new_message)
-        .setContentTitle("Message from Travis")
-        .setContentText("I love key lime pie!")
-        .setContentIntent(replyPendingIntent);
-
-// Create the remote input
-RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
-        .setLabel(replyLabel)
-        .build();
-
-// Create wearable notification and add remote input
-Notification replyNotification =
-        new WearableNotifications.Builder(replyNotificationBuilder)
-        .addRemoteInputForContentIntent(remoteInput)
-        .build();
-
- - -

By using - -addRemoteInputForContentIntent() to add the - RemoteInput object to the notification's primary action, -the button that normally appears as an "Open" action becomes the "Reply" action -and starts the voice input UI when users select it on Android Wear.

- - - -

Receive Voice Input for a Secondary Action

- -

If the "Reply" action is not your notification's primary action and you want to enable -voice input for a secondary action, add the - RemoteInput to a new action button defined by an - -Action object.

- -

You should instantiate the - -Action with the - Action.Builder() -constructor, which takes an icon and text label for the action button, plus the -PendingIntent -the system should use to invoke your app when the user selects the action. For example:

- -
-// Create the pending intent to fire when the user selects the action
-Intent replyIntent = new Intent(this, ReplyActivity.class);
-PendingIntent pendingReplyIntent =
-        PendingIntent.getActivity(this, 0, replyIntent, 0);
-
-// Create the remote input
-RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
-        .setLabel(replyLabel)
-        .build();
-
-// Create the notification action
-Action replyAction = new Action.Builder(R.drawable.ic_message,
-        "Reply", pendingIntent)
-        .addRemoteInput(remoteInput)
-        .build();
-
- - -

After you add the - RemoteInput to the - -Action, add the - -Action to the - WearableNotifications.Builder using - addAction(). -For example:

- -
-// Create basic notification builder
-NotificationCompat.Builder replyNotificationBuilder =
-        new NotificationCompat.Builder(this)
-        .setContentTitle("New message");
-
-// Create the notification action and add remote input
-Action replyAction = new Action.Builder(R.drawable.ic_message,
-        "Reply", pendingIntent)
-        .addRemoteInput(remoteInput)
-        .build();
-
-// Create wearable notification and add action
-Notification replyNotification =
-        new WearableNotifications.Builder(replyNotificationBuilder)
-        .addAction(replyAction)
-        .build();
-
- -

Now, when the user selects "Reply" from an Android wearable, the system prompts the user - for voice input (and shows the list of pre-defined replies, if provided). - Once the user completes a response, the system invokes - the Intent attached to the action and adds the -EXTRA_VOICE_REPLY extra (the string - you passed to the - RemoteInput.Builder constructor) - with the user's message as the string value.

- - - - - - - -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/notifications/remote-input.jd b/docs/html/wear/notifications/remote-input.jd new file mode 100644 index 0000000000000..a3d45df5fbe30 --- /dev/null +++ b/docs/html/wear/notifications/remote-input.jd @@ -0,0 +1,213 @@ +page.title=Receiving Voice Input from a Notification + +@jd:body + + + + + +

If your notification includes an action to respond with text, + such as to reply to an email, it should normally launch an activity + on the handheld device. However, when your notification appears on an Android wearable, you can + allow users to dictate a reply with voice input. You can also provide pre-defined text + messages for the user to select.

+ +

When the user replies with voice or selects one of the available +messages, the system sends the message to your app on the connected handheld device. +The message is attached as an extra in the {@link android.content.Intent} you specified +to be used for the notification action.

+ +

Note: When developing with the Android emulator, +you must type text replies into the voice input field, so be sure you have enabled +Hardware keyboard present in the AVD settings.

+ + +

Define the Remote Input

+ +

To create an action that supports voice input, first create an instance of + +RemoteInput using the + RemoteInput.Builder APIs. + The + RemoteInput.Builder constructor takes a string that the system + will use as a key for the {@link android.content.Intent} extra that carries the reply message + to your app on the handheld.

+ +

For example, here's how to create a new + +RemoteInput object that provides a custom + label for the voice input prompt:

+ +
+// Key for the string that's delivered in the action's intent
+private static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
+
+String replyLabel = getResources().getString(R.string.reply_label);
+
+RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
+        .setLabel(replyLabel)
+        .build();
+
+ + +

Add Pre-defined Text Responses

+ + + +

In addition to allowing voice input, you can + provide up to five text responses that the user can select for quick replies. Call + setChoices() and pass it a string array.

+ +

For example, you may define some responses in a resource array:

+ +

res/values/strings.xml +

+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string-array name="reply_choices">
+        <item>Yes</item>
+        <item>No</item>
+        <item>Maybe</item>
+    </string-array>
+</resources>
+
+ +

Then, inflate the string array and add it to the + RemoteInput:

+ +
+String replyLabel = getResources().getString(R.string.reply_label);
+String[] replyChoices = getResources().getStringArray(R.array.reply_choices);
+
+RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
+        .setLabel(replyLabel)
+        .setChoices(replyChoices)
+        .build();
+
+ + + + +

Receive Voice Input for the Primary Action

+ +

If "Reply" is your notification's primary action (defined by the {@link +android.support.v4.app.NotificationCompat.Builder#setContentIntent setContentIntent()} +method), then you should attach the + RemoteInput to the main action using + +addRemoteInputForContentIntent(). For example:

+ +
+// Create intent for reply action
+Intent replyIntent = new Intent(this, ReplyActivity.class);
+PendingIntent replyPendingIntent =
+        PendingIntent.getActivity(this, 0, replyIntent, 0);
+
+// Build the notification
+NotificationCompat.Builder replyNotificationBuilder =
+        new NotificationCompat.Builder(this)
+        .setSmallIcon(R.drawable.ic_new_message)
+        .setContentTitle("Message from Travis")
+        .setContentText("I love key lime pie!")
+        .setContentIntent(replyPendingIntent);
+
+// Create the remote input
+RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
+        .setLabel(replyLabel)
+        .build();
+
+// Create wearable notification and add remote input
+Notification replyNotification =
+        new WearableNotifications.Builder(replyNotificationBuilder)
+        .addRemoteInputForContentIntent(replyAction)
+        .build();
+
+ + +

By using + +addRemoteInputForContentIntent() to add the + RemoteInput object to the notification's primary action, +the button that normally appears as an "Open" action becomes the "Reply" action +and starts the voice input UI when users select it on Android Wear.

+ + + +

Receive Voice Input for a Secondary Action

+ +

If the "Reply" action is not your notification's primary action and you want to enable +voice input for a secondary action, add the + RemoteInput to a new action button defined by an + +Action object.

+ +

You should instantiate the + +Action with the + Action.Builder() +constructor, which takes an icon and text label for the action button, plus the +{@link android.app.PendingIntent} +the system should use to invoke your app when the user selects the action. For example:

+ +
+// Create the pending intent to fire when the user selects the action
+Intent replyIntent = new Intent(this, ReplyActivity.class);
+PendingIntent pendingReplyIntent =
+        PendingIntent.getActivity(this, 0, replyIntent, 0);
+
+// Create the remote input
+RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
+        .setLabel(replyLabel)
+        .build();
+
+// Create the notification action
+Action replyAction = new Action.Builder(R.drawable.ic_message,
+        "Reply", pendingIntent)
+        .addRemoteInput(remoteInput)
+        .build();
+
+ + +

After you add the + RemoteInput to the + +Action, add the + +Action to the + WearableNotifications.Builder using + addAction(). +For example:

+ +
+// Create basic notification builder
+NotificationCompat.Builder replyNotificationBuilder =
+        new NotificationCompat.Builder(this)
+        .setContentTitle("New message");
+
+// Create the notification action and add remote input
+Action replyAction = new Action.Builder(R.drawable.ic_message,
+        "Reply", pendingIntent)
+        .addRemoteInput(remoteInput)
+        .build();
+
+// Create wearable notification and add action
+Notification replyNotification =
+        new WearableNotifications.Builder(replyNotificationBuilder)
+        .addAction(replyAction)
+        .build();
+
+ +

Now, when the user selects "Reply" from an Android wearable, the system prompts the user + for voice input (and shows the list of pre-defined replies, if provided). + Once the user completes a response, the system invokes + the {@link android.content.Intent} attached to the action and adds the +EXTRA_VOICE_REPLY extra (the string + you passed to the + RemoteInput.Builder constructor) + with the user's message as the string value.

+ + + + + + diff --git a/docs/html/wear/notifications/stacks.html b/docs/html/wear/notifications/stacks.html deleted file mode 100644 index e4f74a037b10c..0000000000000 --- a/docs/html/wear/notifications/stacks.html +++ /dev/null @@ -1,512 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Stacking Notifications | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - -
- - - - - -

Stacking Notifications

- - - - - - -
- - -
- - - -

When creating notifications for a handheld device, you should always aggregate similar -notifications into a single summary notification. For example, if your app creates notifications -for received messages, you should not show more than one notification -on a handheld device—when more than one is message is received, use a single notification -to provide a summary such as "2 new messages."

- -

However, a summary notification is less useful on an Android wearable because users -are not able to read details from each message on the wearable (they must open your app on the -handheld to view more information). So for the wearable device, you should -group all the notifications together in a stack. The stack of notifications appears as a single -card, which users can expand to view the details from each notification separately. The new - -setGroup() method makes this possible while allowing you to still provide -only one summary notification on the handheld device.

- -

For details about designing notification stacks, see the -Design Principles of Android -Wear.

- - -

Add Each Notification to a Group

- -

To create a stack, call -setGroup() for each notification you want in the stack, passing the same -group key. For example:

- -
-final static String GROUP_KEY_EMAILS = "group_key_emails";
-
-NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
-         .setContentTitle("New mail from " + sender)
-         .setContentText(subject)
-         .setSmallIcon(R.drawable.new_mail);
-
-Notification notif = new WearableNotifications.Builder(builder)
-         .setGroup(GROUP_KEY_EMAILS)
-         .build();
-
- -

By default, notifications appear in the order in which you added them, with the most recent - notification visible at the top. You can define a specific position in the group - by passing an order position as the second parameter for -setGroup().

- - -

Add a Summary Notification

- -

It's important that you still provide a summary notification that appears on handheld devices. -So in addition to adding each unique notification to the same stack group, also add a summary -notification, but set its order position to be GROUP_ORDER_SUMMARY.

- -
-Notification summaryNotification = new WearableNotifications.Builder(builder)
-         .setGroup(GROUP_KEY_EMAILS, WearableNotifications.GROUP_ORDER_SUMMARY)
-         .build();
-
- -

This notification will not appear in your stack of notifications on the wearable, but -appears as the only notification on the handheld device. - - - - -

- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/notifications/stacks.jd b/docs/html/wear/notifications/stacks.jd new file mode 100644 index 0000000000000..7f955f67634e8 --- /dev/null +++ b/docs/html/wear/notifications/stacks.jd @@ -0,0 +1,72 @@ +page.title=Stacking Notifications + +@jd:body + + + + +

When creating notifications for a handheld device, you should always aggregate similar +notifications into a single summary notification. For example, if your app creates notifications +for received messages, you should not show more than one notification +on a handheld device—when more than one is message is received, use a single notification +to provide a summary such as "2 new messages."

+ +

However, a summary notification is less useful on an Android wearable because users +are not able to read details from each message on the wearable (they must open your app on the +handheld to view more information). So for the wearable device, you should +group all the notifications together in a stack. The stack of notifications appears as a single +card, which users can expand to view the details from each notification separately. The new + +setGroup() method makes this possible while allowing you to still provide +only one summary notification on the handheld device.

+ +

For details about designing notification stacks, see the +Design Principles of Android +Wear.

+ + +

Add Each Notification to a Group

+ +

To create a stack, call +setGroup() for each notification you want in the stack, passing the same +group key. For example:

+ +
+final static String GROUP_KEY_EMAILS = "group_key_emails";
+
+NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
+         .setContentTitle("New mail from " + sender)
+         .setContentText(subject)
+         .setSmallIcon(R.drawable.new_mail);
+
+Notification notif = new WearableNotifications.Builder(builder)
+         .setGroup(GROUP_KEY_EMAILS)
+         .build();
+
+ +

By default, notifications appear in the order in which you added them, with the most recent + notification visible at the top. You can define a specific position in the group + by passing an order position as the second parameter for +setGroup().

+ + +

Add a Summary Notification

+ +

It's important that you still provide a summary notification that appears on handheld devices. +So in addition to adding each unique notification to the same stack group, also add a summary +notification, but set its order position to be GROUP_ORDER_SUMMARY.

+ +
+Notification summaryNotification = new WearableNotifications.Builder(builder)
+         .setGroup(GROUP_KEY_EMAILS, WearableNotifications.GROUP_ORDER_SUMMARY)
+         .build();
+
+ +

This notification will not appear in your stack of notifications on the wearable, but +appears as the only notification on the handheld device. + + + diff --git a/docs/html/wear/preview/signup.html b/docs/html/wear/preview/signup.jd similarity index 65% rename from docs/html/wear/preview/signup.html rename to docs/html/wear/preview/signup.jd index ca50179e6f883..8e8ec9a1e781c 100644 --- a/docs/html/wear/preview/signup.html +++ b/docs/html/wear/preview/signup.jd @@ -1,379 +1,8 @@ - +page.title=Sign Up for the Developer Preview +@jd:body - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Sign Up for the Developer Preview | Android Developers - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - -
-
- -
- - - - - -
- - - - - -

Sign Up for the Developer Preview

- - - - - - -
- - -
-

To get started with the Android Wear Developer Preview, you must agree to the +

To get started with the Android Wear Developer Preview, you must agree to the following terms and conditions and provide the email address for your Google account. After signing up, you’ll have access to:

    @@ -538,72 +167,3 @@ This is the Android Wear Developer Preview License Agreement. - -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/preview/start.html b/docs/html/wear/preview/start.html deleted file mode 100644 index b1861f5f36baa..0000000000000 --- a/docs/html/wear/preview/start.html +++ /dev/null @@ -1,693 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Get Started with the Developer Preview | Android Developers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - - - - -
- - - - - -

Get Started with the Developer Preview

- - - - - - -
- - -
-
- -
-

The Android Wear Developer Preview includes tools and APIs that allow you to -enhance your app notifications -to provide an optimized user experience on Android wearables.

- -

With the Android Wear Developer Preview, you can:

- -
    -
  • Run the Android Wear platform in the Android emulator.
  • -
  • Connect your Android device to the emulator and view notifications from the -device as cards on Android Wear.
  • -
  • Try new APIs in the preview support library that enhance your app's notifications -with features such as voice replies and notification pages.
  • -
- -

To get access to the Developer Preview tools, -click the sign up button on the right, then follow the setup instructions below.

-
- -
- - -Sign Up for the Developer Preview - -

Signing up provides you access to:

-
    -
  • New notification APIs in the preview support library.
  • -
  • Sample apps using the new notification APIs.
  • -
  • The Android Wear Preview app for your mobile device, which connects -your device to the Android Wear emulator.
  • -
- -
-
- - -

Caution: -The current Android Wear Developer Preview is intended for development and testing purposes only, not for production apps. Google may change this Developer Preview significantly prior to the official release of the Android Wear SDK. You may not publicly distribute or ship any application using this Developer Preview, as this Developer Preview will no longer be supported after the official SDK is released (which will cause applications based only on the Developer Preview to break).

- - - - -

Prerequisites

- -

Before you begin the setup, you must:

- -
    -
  1. Install the Android SDK. -

    The Android SDK includes all the developer tools required to build -apps for Android (optional IDEs are also available for download).

  2. -
  3. Sign up for the Android Wear Developer Preview. -

    You must sign up with a Gmail or other Google account in order to download the -preview support library and receive access to the -Android Wear Preview beta app on Google Play Store.

  4. -
- -

Note: -If you're using the ADT plugin for Eclipse, you must update to version 22.6.1 or higher. -If you're using Android Studio, you must update to version 0.5.1 or higher

- - - -

1. Install the Android Wear System Image

- - -
    -
  1. Launch Android SDK Manager. -
      -
    • From Eclipse, select Window > Android SDK Manager.
    • -
    • From Android Studio, select Tools > Android > SDK Manager.
    • -
    -
  2. -
  3. Below Tools, verify that you have Android SDK Tools revision 22.6 or higher. -

    If your version of Android SDK Tools is lower than 22.6, you must update:

    -
      -
    1. Select Android SDK Tools.
    2. -
    3. Click Install package.
    4. -
    5. Accept the license and click Install.
    6. -
    7. When the installation completes, restart Android SDK Manager.
    8. -
    -
  4. - -
  5. Below Android 4.4.2, select Android Wear ARM EABI v7a System Image. -

    Note: Android Wear is designed to support multiple processor architectures. -

  6. -
  7. Below Extras, ensure that you have the latest version of the -Android Support Library. - If an update is available, select Android Support Library. If you're using Android Studio, also select Android Support Repository.
  8. -
  9. Click Install packages.
  10. -
  11. Accept the license and click Install.
  12. -
- - - -

2. Set Up the Android Wear Emulator

- -
    -
  1. Launch the Android Virtual Device Manager. -
      -
    • From Eclipse, select Window > Android Virtual Device Manager.
    • -
    • From Android Studio, select Tools > Android > AVD Manager.
    • -
    -
  2. -
  3. Click New.
  4. -
  5. For the AVD Name, enter "AndroidWearSquare" or "AndroidWearRound", depending on whether -you want to create an emulator with a square or round display.
  6. -
  7. For the Device, select Android Wear Square or - Android Wear Round.
  8. -
  9. For the Target, select Android 4.4.2 - API Level 19 (or higher).
  10. -
  11. For the CPU/ABI, select Android Wear ARM (armeabi-v7a). -

    Note: Android Wear is designed to support multiple processor architectures. -

  12. -
  13. For the Skin, select AndroidWearSquare or -AndroidWearRound.
  14. -
  15. Leave all other options set to their defaults and click OK. -

    Although real Android wearables do not provide a keyboard as an input method, - you should keep Hardware keyboard present selected so you can - provide text input on screens where users will instead provide voice input.

    -
  16. - -
  17. In the list of AVDs, select the one you just created and click - Start. In the following window, click Launch.
  18. -
- -

The Android Wear emulator now starts. To begin testing your app's notifications, -you must now pair the emulator to your development device -that has the Android Wear Preview app installed.

- -

Tip: To improve the emulator startup time, edit your AVD -and enable Snapshot under Emulator Options. When you start the emulator, -select Save to snapshot then click Launch. Once the emulator -is running, close it to save a snapshot of the system. -Start the AVD again, but select Launch from snapshot and -deselect Save to snapshot.

- -

Caution: Do not install apps on the Android Wear emulator. -The system does not support traditional Android apps and the result of running such apps is -unpredictable.

- - - -

3. Set Up the Android Wear Preview App

- -

To view your app's notifications on the Android Wear emulator, you must have the -Android Wear Preview app installed on your Android device (a phone or tablet).

- -

To receive the Android Wear Preview app, you must sign up for the Developer Preview using the same -Gmail or Google account you use with Google Play Store.

-

- -

Note: The Android Wear Preview app is compatible with - Android 4.3 and higher and is not available for the Android emulator.

- -

After you've signed up for the Developer Preview, - you'll receive a confirmation email that includes a link to opt-in to the - Android Wear Preview app beta program. Once you opt-in, it may take up to 24 hours for the - app to become available in Google Play Store.

- -

After you install the Android Wear Preview app, you can set up - your device to communicate with the Android Wear emulator:

- -
    -
  1. Open the Android Wear Preview app. You should see a notice that the app is currently - not enabled as a notification listener. Tap the message to open the system settings, - then select Android Wear Preview to grant it notification access.
  2. -
  3. Connect your device to your development machine over USB. Be sure that no other - Android devices are connected to the machine.
  4. -
  5. Ensure that the Android Wear emulator (created in the previous section) is running. -The emulator should show the time and an icon that indicates no device is connected.
  6. -
  7. Open a command line terminal, navigate to your Android SDK's platform-tools/ -directory, then execute: -
    adb -d forward tcp:5601 tcp:5601
    -

    Note: You must execute this command each time you connect your -device over USB.

    -
  8. -
  9. Return to the Android Wear Preview app. It should now indicate that it is connected to - the emulator. The Android Wear emulator should now show the 'g' orb icon, indicating - that is is connected to your device. -
- -

Now, notifications from your device also appear in the Android Wear emulator.

- - - - -

4. Add the Support Library to Your Project

- -

The Android Wear preview support library includes several APIs that allow you to -optimize your app's notifications for the Android Wear user experience.

- -

To receive the preview support library, you must sign up for the Developer Preview. The -confirmation email you receive after you sign up includes a link to download a ZIP file, -which contains the preview support library and some sample apps.

- -

After you download and unzip the package, add the preview support library -sto your Android project:

- -

If you're using Eclipse:

-
    -
  1. In your Android app project, create a libs/ directory in your project root - (the same location as the AndroidManifest.xml file).
  2. -
  3. Copy the v4 support library JAR file from your Android SDK directory (e.g., - <sdk>/extras/android/support/v4/android-support-v4.jar) into your - project libs/ directory. -
  4. Also save the wearable-preview-support.jar file in the libs/ directory. -
  5. Right click each JAR file and select Build Path > Add to Build Path.
  6. -
- -

If you're using Android Studio:

-
    -
  1. In your Android app project, create a libs/ directory in your project root - (the same location as the AndroidManifest.xml file).
  2. -
  3. Save the wearable-preview-support.jar file in the libs/ directory. -
  4. Open the build.gradle file in your app module.
  5. -
  6. Add a dependency rule for both the v4 support library and the Android Wear - preview support library: -
    -dependencies {
    -    compile "com.android.support:support-v4:18.0.+"
    -    compile files('../libs/wearable-preview-support.jar')
    -}
    -
    -
  7. -
  8. Click Sync Project with Gradle Files in the toolbar.
  9. -
- -

To start optimizing your notifications for Android Wear, - read Creating Notifications for Android Wear.

- - - - - - -
- - - - - - -
- - -
- -
- - - - - - - - - - - - - - - diff --git a/docs/html/wear/preview/start.jd b/docs/html/wear/preview/start.jd new file mode 100644 index 0000000000000..f8f012910c457 --- /dev/null +++ b/docs/html/wear/preview/start.jd @@ -0,0 +1,254 @@ +page.title=Get Started with the Developer Preview + +@jd:body + + +
+ +
+

The Android Wear Developer Preview includes tools and APIs that allow you to +enhance your app notifications +to provide an optimized user experience on Android wearables.

+ +

With the Android Wear Developer Preview, you can:

+ + + +

To get access to the Developer Preview tools, +click the sign up button on the right, then follow the setup instructions below.

+
+ +
+ + +Sign Up for the Developer Preview + +

Signing up provides you access to:

+ + +
+
+ + +

Caution: +The current Android Wear Developer Preview is intended for development and testing purposes only, not for production apps. Google may change this Developer Preview significantly prior to the official release of the Android Wear SDK. You may not publicly distribute or ship any application using this Developer Preview, as this Developer Preview will no longer be supported after the official SDK is released (which will cause applications based only on the Developer Preview to break).

+ + + + +

Prerequisites

+ +

Before you begin the setup, you must:

+ +
    +
  1. Install the Android SDK. +

    The Android SDK includes all the developer tools required to build +apps for Android (optional IDEs are also available for download).

  2. +
  3. Sign up for the Android Wear Developer Preview. +

    You must sign up with a Gmail or other Google account in order to download the +preview support library and receive access to the +Android Wear Preview beta app on Google Play Store.

  4. +
+ +

Note: +If you're using the ADT plugin for Eclipse, you must update to version 22.6.1 or higher. +If you're using Android Studio, you must update to version 0.5.1 or higher

+ + + +

1. Install the Android Wear System Image

+ + +
    +
  1. Launch Android SDK Manager. + +
  2. +
  3. Below Tools, verify that you have Android SDK Tools revision 22.6 or higher. +

    If your version of Android SDK Tools is lower than 22.6, you must update:

    +
      +
    1. Select Android SDK Tools.
    2. +
    3. Click Install package.
    4. +
    5. Accept the license and click Install.
    6. +
    7. When the installation completes, restart Android SDK Manager.
    8. +
    +
  4. + +
  5. Below Android 4.4.2, select Android Wear ARM EABI v7a System Image. +

    Note: Android Wear is designed to support multiple processor architectures. +

  6. +
  7. Below Extras, ensure that you have the latest version of the +Android Support Library. + If an update is available, select Android Support Library. If you're using Android Studio, also select Android Support Repository.
  8. +
  9. Click Install packages.
  10. +
  11. Accept the license and click Install.
  12. +
+ + + +

2. Set Up the Android Wear Emulator

+ +
    +
  1. Launch the Android Virtual Device Manager. + +
  2. +
  3. Click New.
  4. +
  5. For the AVD Name, enter "AndroidWearSquare" or "AndroidWearRound", depending on whether +you want to create an emulator with a square or round display.
  6. +
  7. For the Device, select Android Wear Square or + Android Wear Round.
  8. +
  9. For the Target, select Android 4.4.2 - API Level 19 (or higher).
  10. +
  11. For the CPU/ABI, select Android Wear ARM (armeabi-v7a). +

    Note: Android Wear is designed to support multiple processor architectures. +

  12. +
  13. For the Skin, select AndroidWearSquare or +AndroidWearRound.
  14. +
  15. Leave all other options set to their defaults and click OK. +

    Although real Android wearables do not provide a keyboard as an input method, + you should keep Hardware keyboard present selected so you can + provide text input on screens where users will instead provide voice input.

    +
  16. + +
  17. In the list of AVDs, select the one you just created and click + Start. In the following window, click Launch.
  18. +
+ +

The Android Wear emulator now starts. To begin testing your app's notifications, +you must now pair the emulator to your development device +that has the Android Wear Preview app installed.

+ +

Tip: To improve the emulator startup time, edit your AVD +and enable Snapshot under Emulator Options. When you start the emulator, +select Save to snapshot then click Launch. Once the emulator +is running, close it to save a snapshot of the system. +Start the AVD again, but select Launch from snapshot and +deselect Save to snapshot.

+ +

Caution: Do not install apps on the Android Wear emulator. +The system does not support traditional Android apps and the result of running such apps is +unpredictable.

+ + + +

3. Set Up the Android Wear Preview App

+ +

To view your app's notifications on the Android Wear emulator, you must have the +Android Wear Preview app installed on your Android device (a phone or tablet).

+ +

To receive the Android Wear Preview app, you must sign up for the Developer Preview using the same +Gmail or Google account you use with Google Play Store.

+

+ +

Note: The Android Wear Preview app is compatible with + Android 4.3 and higher and is not available for the Android emulator.

+ +

After you've signed up for the Developer Preview, + you'll receive a confirmation email that includes a link to opt-in to the + Android Wear Preview app beta program. Once you opt-in, it may take up to 24 hours for the + app to become available in Google Play Store.

+ +

After you install the Android Wear Preview app, you can set up + your device to communicate with the Android Wear emulator:

+ +
    +
  1. Open the Android Wear Preview app. You should see a notice that the app is currently + not enabled as a notification listener. Tap the message to open the system settings, + then select Android Wear Preview to grant it notification access.
  2. +
  3. Connect your device to your development machine over USB. Be sure that no other + Android devices are connected to the machine.
  4. +
  5. Ensure that the Android Wear emulator (created in the previous section) is running. +The emulator should show the time and an icon that indicates no device is connected.
  6. +
  7. Open a command line terminal, navigate to your Android SDK's platform-tools/ +directory, then execute: +
    adb -d forward tcp:5601 tcp:5601
    +

    Note: You must execute this command each time you connect your +device over USB.

    +
  8. +
  9. Return to the Android Wear Preview app. It should now indicate that it is connected to + the emulator. The Android Wear emulator should now show the 'g' orb icon, indicating + that is is connected to your device. +
+ +

Now, notifications from your device also appear in the Android Wear emulator.

+ + + + +

4. Add the Support Library to Your Project

+ +

The Android Wear preview support library includes several APIs that allow you to +optimize your app's notifications for the Android Wear user experience.

+ +

To receive the preview support library, you must sign up for the Developer Preview. The +confirmation email you receive after you sign up includes a link to download a ZIP file, +which contains the preview support library and some sample apps.

+ +

After you download and unzip the package, add the preview support library +sto your Android project:

+ +

If you're using Eclipse:

+
    +
  1. In your Android app project, create a libs/ directory in your project root + (the same location as the AndroidManifest.xml file).
  2. +
  3. Copy the v4 support library JAR file from your Android SDK directory (e.g., + <sdk>/extras/android/support/v4/android-support-v4.jar) into your + project libs/ directory. +
  4. Also save the wearable-preview-support.jar file in the libs/ directory. +
  5. Right click each JAR file and select Build Path > Add to Build Path.
  6. +
+ +

If you're using Android Studio:

+
    +
  1. In your Android app project, create a libs/ directory in your project root + (the same location as the AndroidManifest.xml file).
  2. +
  3. Save the wearable-preview-support.jar file in the libs/ directory. +
  4. Open the build.gradle file in your app module.
  5. +
  6. Add a dependency rule for both the v4 support library and the Android Wear + preview support library: +
    +dependencies {
    +    compile "com.android.support:support-v4:18.0.+"
    +    compile files('../libs/wearable-preview-support.jar')
    +}
    +
    +
  7. +
  8. Click Sync Project with Gradle Files in the toolbar.
  9. +
+ +

To start optimizing your notifications for Android Wear, + read Creating Notifications for Android Wear.

+ + + + + diff --git a/docs/html/wear/wear_toc.cs b/docs/html/wear/wear_toc.cs new file mode 100644 index 0000000000000..65ac2e9dd12ef --- /dev/null +++ b/docs/html/wear/wear_toc.cs @@ -0,0 +1,74 @@ +