README.md
1 Android MessagingService Sample
2 ===================================
3
4 This sample shows a simple service that sends notifications using
5 NotificationCompat. In addition to sending a notification, it also extends
6 the notification with a CarExtender to make it compatible with Android Auto.
7 Each unread conversation from a user is sent as a distinct notification.
8
9 Introduction
10 ------------
11
12 #### Checklist while building a messaging app that supports Android Auto:
13 1. Ensure that Message notifications are extended using
14 NotificationCompat.Builder.extend(new CarExtender()...)
15 2. Declare a meta-data tag to your AndroidManifest.xml to specify that your app
16 is automotive enabled.
17
18 example: AndroidManifest.xml
19
20 ```
21 <meta-data android:name="com.google.android.gms.car.application"
22 android:resource="@xml/automotive_app_desc"/>
23 ```
24
25 Include the following to indicate that the application wants to show notifications on
26 the Android Auto overview screen.
27
28 example: res/xml/automotive\_app\_desc.xml
29 ```
30 <automotiveApp>
31 <uses name="notification"/>
32 </automotiveApp>
33 ```
34
35 #### Flow
36 MessagingFragment is shown to the user. Depending on the button clicked, the MessagingService is
37 sent a message. MessagingService in turn creates notifications which can be viewed either on the
38 device or in the messaging-simulator.
39
40 When a message is read, the associated PendingIntent is triggered and MessageReadReceiver is called
41 with the appropriate conversationId. Similarly, when a reply is received, the MessageReplyReceiver
42 is called with the appropriate conversationId. MessageLogger logs each event and shows them in a
43 TextView in MessagingFragment for correlation.
44
45 Pre-requisites
46 --------------
47
48 - Android SDK v21
49 - Android Build Tools v21.1.1
50 - Android Support Repository
51
52 Screenshots
53 -------------
54
55 <img src="screenshots/1-main.png" height="400" alt="Screenshot"/> <img src="screenshots/2-onemessage.png" height="400" alt="Screenshot"/> <img src="screenshots/3-threemessages.png" height="400" alt="Screenshot"/>
56
57 Getting Started
58 ---------------
59
60 This sample uses the Gradle build system. To build this project, use the
61 "gradlew build" command or use "Import Project" in Android Studio.
62
63 Support
64 -------
65
66 - Google+ Community: https://plus.google.com/communities/105153134372062985968
67 - Stack Overflow: http://stackoverflow.com/questions/tagged/android
68
69 If you've found an error in this sample, please file an issue:
70 https://github.com/googlesamples/android-MessagingService
71
72 Patches are encouraged, and may be submitted by forking this project and
73 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
74
75 License
76 -------
77
78 Copyright 2014 The Android Open Source Project, Inc.
79
80 Licensed to the Apache Software Foundation (ASF) under one or more contributor
81 license agreements. See the NOTICE file distributed with this work for
82 additional information regarding copyright ownership. The ASF licenses this
83 file to you under the Apache License, Version 2.0 (the "License"); you may not
84 use this file except in compliance with the License. You may obtain a copy of
85 the License at
86
87 http://www.apache.org/licenses/LICENSE-2.0
88
89 Unless required by applicable law or agreed to in writing, software
90 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
91 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
92 License for the specific language governing permissions and limitations under
93 the License.
94