am c79173c7: am 05282133: Merge "docs: Bugfix & minor cleanup for "Providing Messaging for Auto"" into lmp-docs

automerge: b5b9c9b

* commit 'b5b9c9b589c058d9e21ca23976d7574f9c604e38':
  docs: Bugfix & minor cleanup for "Providing Messaging for Auto"
This commit is contained in:
Andrew Solovay
2014-11-21 10:12:52 +00:00
committed by android-build-merger

View File

@ -151,9 +151,9 @@ page.article=true
</p> </p>
<p> <p>
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 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.
</p> </p>
<pre> <pre>
@ -175,7 +175,7 @@ page.article=true
</pre> </pre>
<p> <p>
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 <a href="#handle_actions">Handle User Actions</a>. is discussed in <a href="#handle_actions">Handle User Actions</a>.
</p> </p>
@ -187,7 +187,7 @@ page.article=true
<a href="{@docRoot}tools/support-library/features.html#v4">v4 support library</a>. Use the <a href="{@docRoot}tools/support-library/features.html#v4">v4 support library</a>. Use the
<a href="{@docRoot}tools/help/sdk-manager.html">Android SDK Manager</a> to update the <a href="{@docRoot}tools/help/sdk-manager.html">Android SDK Manager</a> to update the
<em>Extras > Android Support Repository</em> to version 9 or higher and the <em>Extras > Android Support Repository</em> to version 9 or higher and the
<em>Extras > Android Support Library</em> to version 21.1.0 or higher. <em>Extras > Android Support Library</em> to version 21.0.2 or higher.
</p> </p>
<p> <p>
@ -199,7 +199,7 @@ page.article=true
<pre> <pre>
dependencies { dependencies {
... ...
compile 'com.android.support:support-v4:21.1.+' compile 'com.android.support:support-v4:21.0.+'
} }
</pre> </pre>
@ -244,14 +244,15 @@ dependencies {
<h3 id="build_conversation">Build message conversations</h4> <h3 id="build_conversation">Build message conversations</h4>
<p> <p>
Messaging notifications for Auto organize messages into conversations using the {@code Messaging notifications for Auto organize messages into conversations using the {@link
NotificationCompat.CarExtender.UnreadConversation} class, that represents an unread or new 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 portion of a conversation from a particular sender. It contains a list of messages from the
sender. sender.
</p> </p>
<p> <p>
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: as shown in the following example code:
</p> </p>
@ -277,11 +278,12 @@ UnreadConversation.Builder unreadConvBuilder =
</p> </p>
<p> <p>
If your app supports replying to a conversation, you must call the {@code setReplyAction()} 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 {@code method and provide a pending intent to pass that user action back to your app. The
UnreadConversation} object you create must also include a {@link {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation}
android.support.v4.app.RemoteInput} object. This object is required because the Auto user object you create must also include a {@link
receiving this conversation speaks a reply, a the remote input objects lets your app get a text 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. version of the voice reply.
</p> </p>
@ -289,8 +291,9 @@ UnreadConversation.Builder unreadConvBuilder =
<h4 id="conversation-messages">Associate messages with conversations</h4> <h4 id="conversation-messages">Associate messages with conversations</h4>
<p> <p>
Messages provided for Auto must be associated with a conversation using the {@code Messages provided for Auto must be associated with a conversation using the
NotificationCompat.CarExtender.UnreadConversation} class. The following code example shows how {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation}
class. The following code example shows how
to associate individual messages with a conversation object. to associate individual messages with a conversation object.
</p> </p>
@ -327,18 +330,18 @@ for (Iterator&lt;String&gt; messages = conversation.getMessages().iterator();
Intent msgHeardIntent = new Intent() Intent msgHeardIntent = new Intent()
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
.setAction(<em>com.myapp.messagingservice.ACTION_MESSAGE_HEARD</em>) .setAction(<em>com.myapp.messagingservice.ACTION_MESSAGE_HEARD</em>)
.putExtra("conversation_id", conversationId); .putExtra("conversation_id", <em>conversationId</em>);
PendingIntent msgHeardPendingIntent = PendingIntent msgHeardPendingIntent =
PendingIntent.getBroadcast(getApplicationContext(), PendingIntent.getBroadcast(getApplicationContext(),
conversationId, <em>conversationId</em>,
msgHeardIntent, msgHeardIntent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_UPDATE_CURRENT);
</pre> </pre>
<p> <p>
In this example, {@code conversationId} is an integer that identifies the current conversation. 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 <a href="#manifest-intent">Define read and reply intent defined in your app manifest, as shown in <a href="#manifest-intent">Define read and reply intent
filters</a>. filters</a>.
</p> </p>
@ -365,7 +368,7 @@ PendingIntent msgReplyPendingIntent = PendingIntent.getBroadcast(
<p> <p>
Once again, {@code conversationId} is an integer that uniquely identifies this conversation. The 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 <a href="#manifest-intent">Define read and reply intent filters</a>. app manifest, as shown in <a href="#manifest-intent">Define read and reply intent filters</a>.
</p> </p>
@ -377,8 +380,9 @@ PendingIntent msgReplyPendingIntent = PendingIntent.getBroadcast(
notification to Auto. notification to Auto.
</p> </p>
<p>First, add the message to the <code>UnreadConversation.Builder</code> for <p>First, add the message to the {@link
this conversation, and update its timestamp:</p> android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation.Builder}
for this conversation, and update its timestamp:</p>
<pre> <pre>
unreadConvBuilder.addMessage(<em>messageString</em>) unreadConvBuilder.addMessage(<em>messageString</em>)
@ -402,10 +406,11 @@ NotificationCompat.Builder notificationBuilder =
</pre> </pre>
<p>You'll also need to extend the {@link <p>You'll also need to extend the {@link
android.support.v4.app.NotificationCompat.Builder} with the android.support.v4.app.NotificationCompat.Builder} with the {@link
<code>CarExtender</code>. This is where you actually create the android.support.v4.app.NotificationCompat.CarExtender}. This is where you
<code>UnreadConversation</code> object using the builder you just actually create the {@link android.support.v4.app.NotificationCompat.CarExtender.UnreadConversation} object using the builder you
created, and attach it to the <code>CarExtender</code>:</p> just created, and attach it to the {@link
android.support.v4.app.NotificationCompat.CarExtender}:</p>
<pre> <pre>
notificationBuilder.extend(new CarExtender() notificationBuilder.extend(new CarExtender()
@ -416,14 +421,11 @@ notificationBuilder.extend(new CarExtender()
android.support.v4.app.NotificationManagerCompat} to send the notification:</p> android.support.v4.app.NotificationManagerCompat} to send the notification:</p>
<pre> <pre>
mNotificationManager = NotificationManagerCompat.from(context); NotificationManagerCompat msgNotificationManager =
mNotificationManager.notify(<em>notificationId</em>, notificationBuilder.build()); NotificationManagerCompat.from(context);
msgNotificationManager.notify(<em>notificationId</em>, notificationBuilder.build());
</pre> </pre>
<p>In this example, <em>msgNotificationManager</em> is a
{@link android.support.v4.app.NotificationManagerCompat} you created for your app.</p>
<h2 id="handle_actions">Handle User Actions</h2> <h2 id="handle_actions">Handle User Actions</h2>
<p> <p>