diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/html/guide/topics/manifest/uses-feature-element.jd | 13 | ||||
-rw-r--r-- | docs/html/guide/topics/resources/providing-resources.jd | 4 | ||||
-rw-r--r-- | docs/html/guide/topics/ui/accessibility/services.jd | 3 | ||||
-rw-r--r-- | docs/html/guide/topics/ui/drag-drop.jd | 110 | ||||
-rw-r--r-- | docs/html/training/articles/perf-tips.jd | 1 | ||||
-rw-r--r-- | docs/html/wear/notifications/creating.jd | 86 | ||||
-rw-r--r-- | docs/html/wear/notifications/pages.jd | 28 | ||||
-rw-r--r-- | docs/html/wear/notifications/remote-input.jd | 100 | ||||
-rw-r--r-- | docs/html/wear/notifications/stacks.jd | 56 |
9 files changed, 225 insertions, 176 deletions
diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd index 814396c..ca954fe 100644 --- a/docs/html/guide/topics/manifest/uses-feature-element.jd +++ b/docs/html/guide/topics/manifest/uses-feature-element.jd @@ -584,9 +584,14 @@ is sensitive to delays or lag in sound input or output.</td> </tr> <tr> <td><code>android.hardware.camera.any</code></td> - <td>The application uses at least one camera facing in any direction. Use this -in preference to <code>android.hardware.camera</code> if a back-facing camera is -not required.</td> + <td>The application uses at least one camera facing in any direction, or an +external camera device if one is connected. Use this in preference to +<code>android.hardware.camera</code> if a back-facing camera is not required. + </td> +</tr> +<tr> + <td><code>android.hardware.camera.external</code></td> + <td>The application uses an external camera device if one is connected.</td> </tr> <tr> @@ -1099,4 +1104,4 @@ filtering based on the <code>CAMERA</code> permission, you would add this <td><code>android.hardware.wifi</code></td> <!-- <td></td> --> </tr> -</table>
\ No newline at end of file +</table> diff --git a/docs/html/guide/topics/resources/providing-resources.jd b/docs/html/guide/topics/resources/providing-resources.jd index aec7fa7..bf16630 100644 --- a/docs/html/guide/topics/resources/providing-resources.jd +++ b/docs/html/guide/topics/resources/providing-resources.jd @@ -562,6 +562,7 @@ which indicates the current device orientation.</p> <code>desk</code><br/> <code>television<br/> <code>appliance</code> + <code>watch</code> </td> <td> <ul class="nolist"> @@ -573,8 +574,9 @@ which indicates the current device orientation.</p> non-pointer interaction</li> <li>{@code appliance}: Device is serving as an appliance, with no display</li> + <li>{@code watch}: Device has a display and is worn on the wrist</li> </ul> - <p><em>Added in API level 8, television added in API 13.</em></p> + <p><em>Added in API level 8, television added in API 13, watch added in API 20.</em></p> <p>For information about how your app can respond when the device is inserted into or removed from a dock, read <a href="{@docRoot}training/monitoring-device-state/docking-monitoring.html">Determining diff --git a/docs/html/guide/topics/ui/accessibility/services.jd b/docs/html/guide/topics/ui/accessibility/services.jd index 4bd752f..c868080 100644 --- a/docs/html/guide/topics/ui/accessibility/services.jd +++ b/docs/html/guide/topics/ui/accessibility/services.jd @@ -81,7 +81,8 @@ as shown in the following sample:</p> <pre> <application> <service android:name=".MyAccessibilityService" - android:label="@string/accessibility_service_label"> + android:label="@string/accessibility_service_label" + android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService" /> </intent-filter> diff --git a/docs/html/guide/topics/ui/drag-drop.jd b/docs/html/guide/topics/ui/drag-drop.jd index e989374..9a6b0e9 100644 --- a/docs/html/guide/topics/ui/drag-drop.jd +++ b/docs/html/guide/topics/ui/drag-drop.jd @@ -873,7 +873,7 @@ imageView.setOnDragListener(mDragListen); ... -protected class myDragEventListener implements View.OnDragEventListener { +protected class myDragEventListener implements View.OnDragListener { // This is the method that the system calls when it dispatches a drag event to the // listener. @@ -899,18 +899,15 @@ protected class myDragEventListener implements View.OnDragEventListener { v.invalidate(); // returns true to indicate that the View can accept the dragged data. - return(true); + return true; - } else { + } - // Returns false. During the current drag and drop operation, this View will - // not receive events again until ACTION_DRAG_ENDED is sent. - return(false); + // Returns false. During the current drag and drop operation, this View will + // not receive events again until ACTION_DRAG_ENDED is sent. + return false; - } - break; - - case DragEvent.ACTION_DRAG_ENTERED: { + case DragEvent.ACTION_DRAG_ENTERED: // Applies a green tint to the View. Return true; the return value is ignored. @@ -919,79 +916,70 @@ protected class myDragEventListener implements View.OnDragEventListener { // Invalidate the view to force a redraw in the new tint v.invalidate(); - return(true); - - break; + return true; - case DragEvent.ACTION_DRAG_LOCATION: + case DragEvent.ACTION_DRAG_LOCATION: // Ignore the event - return(true); - - break; - - case DragEvent.ACTION_DRAG_EXITED: - - // Re-sets the color tint to blue. Returns true; the return value is ignored. - v.setColorFilter(Color.BLUE); - - // Invalidate the view to force a redraw in the new tint - v.invalidate(); + return true; - return(true); + case DragEvent.ACTION_DRAG_EXITED: - break; - - case DragEvent.ACTION_DROP: + // Re-sets the color tint to blue. Returns true; the return value is ignored. + v.setColorFilter(Color.BLUE); - // Gets the item containing the dragged data - ClipData.Item item = event.getClipData().getItemAt(0); + // Invalidate the view to force a redraw in the new tint + v.invalidate(); - // Gets the text data from the item. - dragData = item.getText(); + return true; - // Displays a message containing the dragged data. - Toast.makeText(this, "Dragged data is " + dragData, Toast.LENGTH_LONG); + case DragEvent.ACTION_DROP: - // Turns off any color tints - v.clearColorFilter(); + // Gets the item containing the dragged data + ClipData.Item item = event.getClipData().getItemAt(0); - // Invalidates the view to force a redraw - v.invalidate(); + // Gets the text data from the item. + dragData = item.getText(); - // Returns true. DragEvent.getResult() will return true. - return(true); + // Displays a message containing the dragged data. + Toast.makeText(this, "Dragged data is " + dragData, Toast.LENGTH_LONG); - break; + // Turns off any color tints + v.clearColorFilter(); - case DragEvent.ACTION_DRAG_ENDED: + // Invalidates the view to force a redraw + v.invalidate(); - // Turns off any color tinting - v.clearColorFilter(); + // Returns true. DragEvent.getResult() will return true. + return true; - // Invalidates the view to force a redraw - v.invalidate(); + case DragEvent.ACTION_DRAG_ENDED: - // Does a getResult(), and displays what happened. - if (event.getResult()) { - Toast.makeText(this, "The drop was handled.", Toast.LENGTH_LONG); + // Turns off any color tinting + v.clearColorFilter(); - } else { - Toast.makeText(this, "The drop didn't work.", Toast.LENGTH_LONG); + // Invalidates the view to force a redraw + v.invalidate(); - }; + // Does a getResult(), and displays what happened. + if (event.getResult()) { + Toast.makeText(this, "The drop was handled.", Toast.LENGTH_LONG); - // returns true; the value is ignored. - return(true); + } else { + Toast.makeText(this, "The drop didn't work.", Toast.LENGTH_LONG); - break; + } - // An unknown action type was received. - default: - Log.e("DragDrop Example","Unknown action type received by OnDragListener."); + // returns true; the value is ignored. + return true; + // An unknown action type was received. + default: + Log.e("DragDrop Example","Unknown action type received by OnDragListener."); break; - }; - }; + } + + return false; + } }; </pre> diff --git a/docs/html/training/articles/perf-tips.jd b/docs/html/training/articles/perf-tips.jd index 7ff6c5c..1660b7f 100644 --- a/docs/html/training/articles/perf-tips.jd +++ b/docs/html/training/articles/perf-tips.jd @@ -16,7 +16,6 @@ page.article=true <li><a href="#AvoidFloat">Avoid Using Floating-Point</a></li> <li><a href="#UseLibraries">Know and Use the Libraries</a></li> <li><a href="#NativeMethods">Use Native Methods Carefully</a></li> - <li><a href="#library">Know And Use The Libraries</a></li> <li><a href="#native_methods">Use Native Methods Judiciously</a></li> <li><a href="#closing_notes">Closing Notes</a></li> </ol> diff --git a/docs/html/wear/notifications/creating.jd b/docs/html/wear/notifications/creating.jd index ce9e117..a5d7da7 100644 --- a/docs/html/wear/notifications/creating.jd +++ b/docs/html/wear/notifications/creating.jd @@ -44,8 +44,8 @@ library</a> and the Developer Preview support library. So to get started, you should include the following imports in your project code:</p> <pre> -import android.preview.support.wearable.notifications.*; -import android.preview.support.v4.app.NotificationManagerCompat; +import android.support.wearable.notifications.*; +import android.support.wearable.app.NotificationManagerCompat; import android.support.v4.app.NotificationCompat; </pre> @@ -64,7 +64,7 @@ such as action buttons and large icons, while remaining compatible with Android <p>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 -<a href="{@docRoot}reference/android/preview/support/v4/app/NotificationManagerCompat.html"> +<a href="{@docRoot}reference/android/support/wearable/app/NotificationManagerCompat.html"> <code>NotificationManagerCompat</code></a> API:</p> @@ -206,54 +206,70 @@ Wear</a>.</p> 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.</p> -<p>To use these new APIs, pass your instance of -{@link android.support.v4.app.NotificationCompat.Builder} to the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#WearableNotifications.Builder(android.content.Context)"> <code>WearableNotifications.Builder()</code></a> constructor. You can then add new -features to your notification using the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html" - ><code>WearableNotifications.Builder</code></a> methods. For example:</p> +<p>To use these new APIs:</p> + +<ol> + <li>Create an instance of +{@link android.support.v4.app.NotificationCompat.Builder}, setting the +desired properties for your notification.</li> + <li>Create a + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#WearableNotificationOptions.Builder(android.content.Context)"> <code>WearableNotificationOptions.Builder</code></a>, setting the wearable-specific options for the notication.</li> + <li>Call <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#WearableNotificationOptions.Builder#applyTo"><code>WearableNotificationOptions.Builder.applyTo()</code> + </a>, passing in the {@link android.support.v4.app.NotificationCompat.Builder}. This applies + the wearable options to the notification.</li> +</ol> + +<p> +For example, the following code calls the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#setHintHideIcon(boolean)"> + <code>setHintHideIcon()</code></a> method to remove the app icon from the notification card. +</p> <pre> // 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(); + NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext) + .setContentTitle("New mail from " + sender) + .setContentText(subject) + .setSmallIcon(R.drawable.new_mail); +// Create a WearablesNotificationOptions.Builder to add functionality for wearables + Notification notif = new WearableNotificationOptions.Builder() + <b>.setHintHideIcon(true)</b> + .build() + .applyTo(builder); //apply wearable options to to the original notification + .build() </pre> -<p>The <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#setBigActionIcon(int)"> - <code>setHintHideIcon()</code></a> method removes your app icon from the notification card. - This method is just one example of new notification features available from the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html" - ><code>WearableNotifications.Builder</code></a> class.</p> +<p>The + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#setHintHideIcon(boolean)"> + <code>setHintHideIcon()</code></a> method is just one example of new notification features available with the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html" + ><code>WearableNotificationOptions.Builder</code></a> class. +</p> + -<p>When you want to deliver your notifications, be certain to always use the - <a href="{@docRoot}reference/android/preview/support/v4/app/NotificationManagerCompat.html"> - <code>NotificationManagerCompat</code></a> API:</p> +<p>When you want to deliver your notifications, always use the + <a href="{@docRoot}reference/android/support/wearable/app/NotificationManagerCompat.html"> + <code>NotificationManagerCompat</code></a> API instead of + {@link android.app.NotificationManager}:</p> <pre> // 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); +// Issue the notification with notification manager. +notificationManager.notify(notificationId, notif); </pre> -<p>If you instead use the framework's {@link android.app.NotificationManager}, some -features from <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html"><code>WearableNotifications.Builder</code></a> -will not work.</p> + +<p>If you use the framework's {@link android.app.NotificationManager}, some +features from <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html"><code>WearableNotificationOptions.Builder</code></a> +do not work.</p> + <p>To continue enhancing your notifications for wearables using - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html" - ><code>WearableNotifications.Builder</code></a> and other APIs in the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html" + ><code>WearableNotificationOptions.Builder</code></a> and other APIs in the preview support library, see the following developer guides:</p> <dl> diff --git a/docs/html/wear/notifications/pages.jd b/docs/html/wear/notifications/pages.jd index 558f7b8..7d18b3f 100644 --- a/docs/html/wear/notifications/pages.jd +++ b/docs/html/wear/notifications/pages.jd @@ -15,14 +15,19 @@ multiple pages, see the <a href="{@docRoot}wear/design/index.html#NotificationPages">Design Principles of Android Wear</a>.</p> - -<p>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 -<a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#addPage(android.app.Notification)"> +<p>To create a notification with multiple pages:</p> +<ol> + <li>Create the main notification (the first page) the way you'd like the notification to appear on a phone + or tablet.</li> + <li>Add pages one at a time with the +<a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#addPage(android.app.Notification)"> <code>addPage()</code></a> method, or add multiple pages in a {@link java.util.Collection} with the -<a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#addPages(java.util.Collection<android.app.Notification>)"> -<code>addPages()</code></a> method.</p> +<a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#addPages(java.util.Collection<android.app.Notification>)"> +<code>addPages()</code></a> method.</li> + <li>Apply the pages to the main notification with the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.html#applyTo(android.support.v4.app.NotificationCompat.Builder)" + ><code>applyTo()</code></a> method.</li> +</ol> <p>For example, here's some code that adds a second page to a notification:</p> @@ -47,15 +52,14 @@ Notification secondPageNotification = .setStyle(secondPageStyle) .build(); -// Create main notification and add the second page +// Add second page with wearable options and apply to main notification Notification twoPageNotification = - new WearableNotifications.Builder(notificationBuilder) + new WearableNotificationsOptions.Builder() .addPage(secondPageNotification) + .build() + .applyTo(notificationBuilder) .build(); </pre> - - - </body> </html> diff --git a/docs/html/wear/notifications/remote-input.jd b/docs/html/wear/notifications/remote-input.jd index 1668363..4db8274 100644 --- a/docs/html/wear/notifications/remote-input.jd +++ b/docs/html/wear/notifications/remote-input.jd @@ -25,16 +25,16 @@ you must type text replies into the voice input field, so be sure you have enabl <h2 id="RemoteInput">Define the Remote Input</h2> <p>To create an action that supports voice input, first create an instance of - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.html"> + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html"> <code>RemoteInput</code></a> using the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.Builder.html"><code>RemoteInput.Builder</code></a> APIs. + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.Builder.html"><code>RemoteInput.Builder</code></a> APIs. The - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.Builder.html"><code>RemoteInput.Builder</code></a> constructor takes a string that the system + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.Builder.html"><code>RemoteInput.Builder</code></a> 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.</p> <p>For example, here's how to create a new - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.html"> + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html"> <code>RemoteInput</code></a> object that provides a custom label for the voice input prompt:</p> @@ -56,7 +56,7 @@ RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) <p>In addition to allowing voice input, you can provide up to five text responses that the user can select for quick replies. Call - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.Builder.html#setChoices(java.lang.String[])"><code>setChoices()</code></a> and pass it a string array.</p> + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.Builder.html#setChoices(java.lang.String[])"><code>setChoices()</code></a> and pass it a string array.</p> <p>For example, you may define some responses in a resource array:</p> @@ -73,7 +73,7 @@ RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) </pre> <p>Then, inflate the string array and add it to the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a>:</p> + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a>:</p> <pre> String replyLabel = getResources().getString(R.string.reply_label); @@ -93,8 +93,8 @@ RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) <p>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 - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> to the main action using - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#addRemoteInputForContentIntent(android.preview.support.wearable.notifications.RemoteInput)"> + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> to the main action using + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#addRemoteInputForContentIntent(android.support.wearable.notifications.RemoteInput)"> <code>addRemoteInputForContentIntent()</code></a>. For example:</p> <pre> @@ -116,18 +116,19 @@ RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel(replyLabel) .build(); -// Create wearable notification and add remote input +// Add remote input to wearable options and apply to notification Notification replyNotification = - new WearableNotifications.Builder(replyNotificationBuilder) + new WearableNotificationOptions.Builder() .addRemoteInputForContentIntent(remoteInput) + .build() + .applyTo(replyNotificationBuilder) .build(); </pre> - <p>By using - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#addRemoteInputForContentIntent(android.preview.support.wearable.notifications.RemoteInput)"> + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#addRemoteInputForContentIntent(android.support.wearable.notifications.RemoteInput)"> <code>addRemoteInputForContentIntent()</code></a> to add the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> object to the notification's primary action, + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> 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.</p> @@ -137,14 +138,14 @@ and starts the voice input UI when users select it on Android Wear.</p> <p>If the "Reply" action is not your notification's primary action and you want to enable voice input for a secondary action, add the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> to a new action button defined by an - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Action.html"> + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> to a new action button defined by an + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableAction.html"> <code>Action</code></a> object.</p> <p>You should instantiate the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Action.html"> -<code>Action</code></a> with the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Action.Builder.html"><code>Action.Builder()</code></a> + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableAction.html"> +<code>WearableAction</code></a> with the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableAction.Builder.html"><code>WearableAction.Builder()</code></a> 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:</p> @@ -161,7 +162,7 @@ RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .build(); // Create the notification action -Action replyAction = new Action.Builder(R.drawable.ic_message, +WearableAction replyAction = new WearableAction.Builder(R.drawable.ic_message, "Reply", pendingIntent) .addRemoteInput(remoteInput) .build(); @@ -169,45 +170,72 @@ Action replyAction = new Action.Builder(R.drawable.ic_message, <p>After you add the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> to the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Action.html"> -<code>Action</code></a>, add the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Action.html"> -<code>Action</code></a> to the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html"><code>WearableNotifications.Builder</code></a> using - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#addAction(Action)"><code>addAction()</code></a>. + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html"><code>RemoteInput</code></a> to the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableAction.html"> +<code>Wearablection</code></a>, set the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableAction.html"> +<code>WearableAction</code></a> on the + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html"><code>WearableNotifications.Builder</code></a> using + <a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationsOptions.Builder.html#addAction(Action)"><code>addAction()</code></a>. For example:</p> <pre> // Create basic notification builder NotificationCompat.Builder replyNotificationBuilder = new NotificationCompat.Builder(this) - .setContentTitle("New message"); + .setContentTitle("New message"); // Create the notification action and add remote input -Action replyAction = new Action.Builder(R.drawable.ic_message, +WearableAction replyAction = new WearableAction.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(); + new WearableNotificationOptions.Builder() + .addAction(replyAction) + .build() + .applyTo(replyNotificationBuilder) + .build(); </pre> + <p>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 <code>EXTRA_VOICE_REPLY</code> extra (the string you passed to the - <a href="{@docRoot}reference/android/preview/support/wearable/notifications/RemoteInput.Builder.html"><code>RemoteInput.Builder</code></a> constructor) - with the user's message as the string value.</p> - - - + <a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.Builder.html"><code>RemoteInput.Builder</code></a> constructor) + with the user's message as the string value.</p> + +<h2 id="ObtainInput">Obtaining the Voice Input as a String</h2> +<p>To obtain the user's voice input, call +<a href="{@docRoot}reference/android/support/wearable/notifications/RemoteInput.html#getResultsFromIntent(Intent)"><code>getResultsFromIntent()</code></a>, +passing in the "Reply" action's intent. This method returns +a {@link android.os.Bundle} that represents the intent's extras. You can then query the +{@link android.os.Bundle} to obtain the user's voice input string. +</p> +<p> +The following code shows a method that accepts an intent and returns the voice input string, +which is referenced by the <code>EXTRA_VOICE_REPLY</code> key that is used in the previous examples: +</p> +<pre> +/** + * Obtain the intent that started this activity by calling + * Activity.getIntent() and pass it into this method to + * get the associated voice input string. + */ +private String getMessageText(Intent intent) { + Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); + if (remoteInput != null) { + return remoteInput.getString(Intent.EXTRA_VOICE_REPLY); + } + } + return null; +} +</pre> </body> </html> diff --git a/docs/html/wear/notifications/stacks.jd b/docs/html/wear/notifications/stacks.jd index a2d34ce..3c3dc09 100644 --- a/docs/html/wear/notifications/stacks.jd +++ b/docs/html/wear/notifications/stacks.jd @@ -16,7 +16,7 @@ are not able to read details from each message on the wearable (they must open y 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 -<a href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#setGroup(java.lang.String, int)"> +<a href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#setGroup(java.lang.String, int)"> <code>setGroup()</code></a> method makes this possible while allowing you to still provide only one summary notification on the handheld device.</p> @@ -28,21 +28,24 @@ Wear</a>.</p> <h2 id="AddGroup">Add Each Notification to a Group</h2> <p>To create a stack, call <a -href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#setGroup(java.lang.String, int)"> +href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#setGroup(java.lang.String, int)"> <code>setGroup()</code></a> for each notification you want in the stack and specify a -group key. Then call <a href="{@docRoot}reference/android/preview/support/v4/app/NotificationManagerCompat.html#notify(int, android.app.Notification)"><code>notify()</code></a> to send it to the wearable.</p> +group key. Then call <a href="{@docRoot}reference/android/support/wearable/app/NotificationManagerCompat.html#notify(int, android.app.Notification)"><code>notify()</code></a> to send it to the wearable.</p> <pre style="clear:right"> final static String GROUP_KEY_EMAILS = "group_key_emails"; -// Build the notification and pass this builder to WearableNotifications.Builder +// Build the notification NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext) .setContentTitle("New mail from " + sender1) .setContentText(subject1) .setSmallIcon(R.drawable.new_mail); -Notification notif1 = new WearableNotifications.Builder(builder) +// Set the group with WearableNotificationOptions.Builder and apply to the notification +Notification notif1 = new WearableNotificationOptions.Builder() .setGroup(GROUP_KEY_EMAILS) + .build() + .applyTo(builder) .build(); // Issue the notification @@ -52,8 +55,10 @@ notificationManager.notify(notificationId1, notif); </pre> <p>Later on, when you create another notification, specify -the same group key. When you call <a href="{@docRoot}reference/android/preview/support/v4/app/NotificationManagerCompat.html#notify(int, android.app.Notification)"><code>notify()</code></a>, this notification appears -in the same stack as the previous notification, instead of as a new card:</p> +the same group key. When you call +<a href="{@docRoot}reference/android/support/v4/app/NotificationManagerCompat.html#notify(int, android.app.Notification)"><code>notify()</code></a>, +this notification appears in the same stack as the previous notification, +instead of as a new card:</p> <pre style="clear:right"> builder = new NotificationCompat.Builder(mContext) @@ -62,8 +67,10 @@ builder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.drawable.new_mail); // Use the same group as the previous notification -Notification notif2 = new WearableNotifications.Builder(builder) +Notification notif2 = new WearableNotificationOptions.Builder() .setGroup(GROUP_KEY_EMAILS) + .build() + .applyTo(builder) .build(); notificationManager.notify(notificationId2, notif); @@ -72,7 +79,7 @@ notificationManager.notify(notificationId2, notif); <p>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 <a -href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.Builder.html#setGroup(java.lang.String, int)"> +href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationOptions.Builder.html#setGroup(java.lang.String, int)"> <code>setGroup()</code></a>.</p> @@ -83,7 +90,7 @@ href="{@docRoot}reference/android/preview/support/wearable/notifications/Wearabl <p>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 <a -href="{@docRoot}reference/android/preview/support/wearable/notifications/WearableNotifications.html#GROUP_ORDER_SUMMARY"><code>GROUP_ORDER_SUMMARY</code></a>.</p> +href="{@docRoot}reference/android/support/wearable/notifications/WearableNotificationsOptions.html#GROUP_ORDER_SUMMARY"><code>GROUP_ORDER_SUMMARY</code></a>.</p> <p>This notification does not appear in your stack of notifications on the wearable, but appears as the only notification on the handheld device.</p> @@ -92,23 +99,22 @@ appears as the only notification on the handheld device.</p> Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_large_icon); +// Create an InboxStyle notification builder = new NotificationCompat.Builder(this) + .setContentTitle("2 new messages") .setSmallIcon(R.drawable.ic_small_icon) - .setLargeIcon(largeIcon); - -// Use the same group key and pass this builder to InboxStyle notification -WearableNotifications.Builder wearableBuilder = new WearableNotifications - .Builder(builder) - .setGroup(GROUP_KEY_EMAILS, - WearableNotifications.GROUP_ORDER_SUMMARY); - -// Build the final notification to show on the handset -Notification summaryNotification = new NotificationCompat.InboxStyle( - wearableBuilder.getCompatBuilder()) - .addLine("Alex Faaborg Check this out") - .addLine("Jeff Chang Launch Party") - .setBigContentTitle("2 new messages") - .setSummaryText("johndoe@gmail.com") + .setLargeIcon(largeIcon) + .setStyle(new NotificationCompat.InboxStyle() + .addLine("Alex Faaborg Check this out") + .addLine("Jeff Chang Launch Party") + .setBigContentTitle("2 new messages") + .setSummaryText("johndoe@gmail.com")); + +// Specify the notification to be the group summary +Notification summaryNotification = new WearableNotificationOptions.Builder() + .setGroupSummary(GROUP_KEY_EMAILS) + .build() + .applyTo(builder) .build(); notificationManager.notify(notificationId3, summaryNotification); |