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