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