From 9ab79ccd34aa28f8c45652947caca9e0ca67c706 Mon Sep 17 00:00:00 2001 From: Andrew Solovay Date: Wed, 19 Nov 2014 10:41:04 -0800 Subject: docs: Bugfix & minor cleanup for "Providing Messaging for Auto" Fixeds the gradle dependency line. Also added in Javadoc links for the various support classes and methods, and other minor cleanup. See first comment for doc stage location. bug: 18439090 Change-Id: I7ccc892f38a644d68abc6d56d8d4377df5f864b0 --- docs/html/training/auto/messaging/index.jd | 64 +++++++++++++++--------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/docs/html/training/auto/messaging/index.jd b/docs/html/training/auto/messaging/index.jd index c51ad7ee4318..2405d8320930 100644 --- a/docs/html/training/auto/messaging/index.jd +++ b/docs/html/training/auto/messaging/index.jd @@ -151,9 +151,9 @@ page.article=true

- You define the read action and reply action intents types for your app and the {@code + You define the read action and reply action intents types for your app and the {@link android.content.BroadcastReceiver} classes that handle them in the manifest. The following code - example demonstrates how to declare these intents and thier associated receivers. + example demonstrates how to declare these intents and their associated receivers.

@@ -175,7 +175,7 @@ page.article=true
 

- The definition of the {@code android.content.BroadcastReceiver} classes shown in this example + The definition of the {@link android.content.BroadcastReceiver} classes shown in this example is discussed in Handle User Actions.

@@ -187,7 +187,7 @@ page.article=true v4 support library. Use the Android SDK Manager to update the Extras > Android Support Repository to version 9 or higher and the - Extras > Android Support Library to version 21.1.0 or higher. + Extras > Android Support Library to version 21.0.2 or higher.

@@ -199,7 +199,7 @@ page.article=true

 dependencies {
     ...
-    compile 'com.android.support:support-v4:21.1.+'
+    compile 'com.android.support:support-v4:21.0.+'
 }
 
@@ -244,14 +244,15 @@ dependencies {

Build message conversations

- Messaging notifications for Auto organize messages into conversations using the {@code - NotificationCompat.CarExtender.UnreadConversation} class, that represents an unread or new + Messaging notifications for Auto organize messages into conversations using the {@link + android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation} class, + that represents an unread or new portion of a conversation from a particular sender. It contains a list of messages from the sender.

- Use the {@code UnreadConversation.Builder} class to create an unread conversation object, + Use the {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation.Builder} class to create an unread conversation object, as shown in the following example code:

@@ -277,11 +278,12 @@ UnreadConversation.Builder unreadConvBuilder =

- If your app supports replying to a conversation, you must call the {@code setReplyAction()} - method and provide a pending intent to pass that user action back to your app. The {@code - UnreadConversation} object you create must also include a {@link - android.support.v4.app.RemoteInput} object. This object is required because the Auto user - receiving this conversation speaks a reply, a the remote input objects lets your app get a text + If your app supports replying to a conversation, you must call the {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation.Builder#setReplyAction setReplyAction()} + method and provide a pending intent to pass that user action back to your app. The + {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation} + object you create must also include a {@link + android.support.v4.app.RemoteInput} object. When the Auto user + receiving this conversation speaks a reply, the remote input objects lets your app get a text version of the voice reply.

@@ -289,8 +291,9 @@ UnreadConversation.Builder unreadConvBuilder =

Associate messages with conversations

- Messages provided for Auto must be associated with a conversation using the {@code - NotificationCompat.CarExtender.UnreadConversation} class. The following code example shows how + Messages provided for Auto must be associated with a conversation using the + {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation} + class. The following code example shows how to associate individual messages with a conversation object.

@@ -327,18 +330,18 @@ for (Iterator<String> messages = conversation.getMessages().iterator(); Intent msgHeardIntent = new Intent() .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) .setAction(com.myapp.messagingservice.ACTION_MESSAGE_HEARD) - .putExtra("conversation_id", conversationId); + .putExtra("conversation_id", conversationId); PendingIntent msgHeardPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), - conversationId, + conversationId, msgHeardIntent, PendingIntent.FLAG_UPDATE_CURRENT);

In this example, {@code conversationId} is an integer that identifies the current conversation. - The value of {@code setAction()} is an intent filter identifier for heard messages which is + The value of {@link android.content.Intent#setAction setAction()} is an intent filter identifier for heard messages which is defined in your app manifest, as shown in Define read and reply intent filters.

@@ -365,7 +368,7 @@ PendingIntent msgReplyPendingIntent = PendingIntent.getBroadcast(

Once again, {@code conversationId} is an integer that uniquely identifies this conversation. The - value of {@code setAction()} is an intent filter identifier for replies which is defined in your + value of {@link android.content.Intent#setAction setAction()} is an intent filter identifier for replies which is defined in your app manifest, as shown in Define read and reply intent filters.

@@ -377,8 +380,9 @@ PendingIntent msgReplyPendingIntent = PendingIntent.getBroadcast( notification to Auto.

-

First, add the message to the UnreadConversation.Builder for -this conversation, and update its timestamp:

+

First, add the message to the {@link +android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation.Builder} +for this conversation, and update its timestamp:

 unreadConvBuilder.addMessage(messageString)
@@ -402,10 +406,11 @@ NotificationCompat.Builder notificationBuilder =
 

You'll also need to extend the {@link -android.support.v4.app.NotificationCompat.Builder} with the -CarExtender. This is where you actually create the -UnreadConversation object using the builder you just -created, and attach it to the CarExtender:

+android.support.v4.app.NotificationCompat.Builder} with the {@link +android.support.v4.app.NotificationCompat.CarExtender}. This is where you +actually create the {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation} object using the builder you +just created, and attach it to the {@link +android.support.v4.app.NotificationCompat.CarExtender}:

 notificationBuilder.extend(new CarExtender()
@@ -416,14 +421,11 @@ notificationBuilder.extend(new CarExtender()
 android.support.v4.app.NotificationManagerCompat} to send the notification:

-mNotificationManager = NotificationManagerCompat.from(context);
-mNotificationManager.notify(notificationId, notificationBuilder.build());
+NotificationManagerCompat msgNotificationManager =
+    NotificationManagerCompat.from(context);
+msgNotificationManager.notify(notificationId, notificationBuilder.build());
 
-

In this example, msgNotificationManager is a -{@link android.support.v4.app.NotificationManagerCompat} you created for your app.

- -

Handle User Actions

-- cgit v1.2.3-59-g8ed1b