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