• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright 2013 The Android Open Source Project
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<sample>
18    <name>MessagingService</name>
19    <group>Android N Preview</group>
20    <package>com.example.android.messagingservice</package>
21
22    <minSdk>21</minSdk>
23    <compileSdkVersion>24</compileSdkVersion>
24    <targetSdkVersion>24</targetSdkVersion>
25
26    <strings>
27        <intro>
28            <![CDATA[
29This sample shows a simple service that sends notifications using
30NotificationCompat. It also extends the notification with Remote
31Input to allow Android N devices to reply via text directly from
32the notification without having to open an app. The same Remote
33Input usage also allows Android Auto users to respond by voice
34when the notifications is presented in that experience.
35Note: Each unread conversation from a user is sent as a distinct
36notification.
37            ]]>
38        </intro>
39    </strings>
40
41    <template src="base-build" />
42    <template src="base-application" />
43    <metadata>
44        <status>PUBLISHED</status>
45        <categories>Android N Preview</categories>
46        <!-- Old Categories: UI, Notification -->
47        <technologies>Android</technologies>
48        <languages>Java</languages>
49        <solutions>Mobile</solutions>
50        <level>ADVANCED</level>
51        <icon>screenshots/icon-web.png</icon>
52        <screenshots>
53            <img>screenshots/1-main.png</img>
54            <img>screenshots/2-onemessage.png</img>
55            <img>screenshots/3-threemessages.png</img>
56        </screenshots>
57        <api_refs>
58            <android>android.app.Service</android>
59            <android>android.content.Intent</android>
60            <android>android.support.v4.app.NotificationCompat</android>
61            <android>android.support.v4.app.NotificationCompat.CarExtender</android>
62        </api_refs>
63        <description>
64<![CDATA[
65This sample shows a simple service that sends notifications using
66NotificationCompat. It also extends the notification with Remote
67Input to allow Android N devices to reply via text directly from
68the notification without having to open an App. The same Remote
69Input object also allows Android Auto users to respond by voice
70when the notification is presented there.
71Note: Each unread conversation from a user is sent as a distinct
72notification.
73]]></description>
74        <intro>
75            <![CDATA[
76#### Checklist while building a messaging app that supports Android Auto:
771. Ensure that Message notifications are extended using
78NotificationCompat.Builder.extend(new CarExtender()...)
792. Declare a meta-data tag to your AndroidManifest.xml to specify that your app
80is automotive enabled.
81
82example: AndroidManifest.xml
83
84```
85       <meta-data android:name="com.google.android.gms.car.application"
86                   android:resource="@xml/automotive_app_desc"/>
87```
88
89Include the following to indicate that the application wants to show notifications on
90the Android Auto overview screen.
91
92example: res/xml/automotive\_app\_desc.xml
93```
94        <automotiveApp>
95            <uses name="notification"/>
96        </automotiveApp>
97```
98
99#### Flow
100MessagingFragment is shown to the user. Depending on the button clicked, the MessagingService is
101sent a message. MessagingService in turn creates notifications which can be viewed either on the
102device or in the messaging-simulator.
103
104When a message is read, the associated PendingIntent is triggered and MessageReadReceiver is called
105with the appropriate conversationId. Similarly, when a reply is received, the MessageReplyReceiver
106is called with the appropriate conversationId. MessageLogger logs each event and shows them in a
107TextView in MessagingFragment for correlation.
108]]>
109        </intro>
110    </metadata>
111</sample>
112