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>ActiveNotifications</name> 19 <group>Android N Preview</group> 20 <package>com.example.android.activenotifications</package> 21 22 <minSdk>24</minSdk> 23 <compileSdkVersion>24</compileSdkVersion> 24 <targetSdkVersion>24</targetSdkVersion> 25 26 <strings> 27 <intro> 28 <![CDATA[ 29Notifications can now be grouped in Android N. Since Android M, the 30NotificationManager can tell you how many notifications your application 31is currently showing. This sample demonstrates how to use these APIs 32together for a nicer user experience when an app may have multiple 33notifications. To get started, press the "add a notification" button. 34If you add more than one notification a notification summary will be 35added. When a notification is being canceled, the count gets updated 36via a PendingIntent. 37 ]]> 38 </intro> 39 </strings> 40 41 <template src="base" /> 42 <template src="FragmentView" /> 43 <common src="activities" /> 44 <common src="logger" /> 45 46 <metadata> 47 <status>DRAFT</status> 48 <categories>Getting Started, Notification, Android N Preview</categories> 49 <technologies>Android</technologies> 50 <languages>Java</languages> 51 <solutions>Mobile</solutions> 52 <level>INTERMEDIATE</level> 53 <icon>screenshots/icon-web.png</icon> 54 <screenshots> 55 <img>screenshots/screenshot01.png</img> 56 <img>screenshots/screenshot02.png</img> 57 <img>screenshots/screenshot03.png</img> 58 </screenshots> 59 <api_refs> 60 <android>android.app.NotificationManager</android> 61 </api_refs> 62 <description> 63<![CDATA[ 64Notification Groups and the Notification Manager can be used together to simplify 65how users experience notifications. This sample demonstrates how 66the NotificationManager can tell you how many notifications your 67application is currently showing. It also shows how to manage the 68notifications as a group and introduce a summary for the group, when 69supported by the platform. 70]]> 71 </description> 72 <intro> 73<![CDATA[ 74Notifications can now be grouped. 75 76Starting with Android N, you can set notification groups for notifications 77and define a notification group summary. 78 79In Android M, you can query for the active notifications that your app sent 80sing the [notify][2] methods. 81 82This sample demonstrates simple use of these features by allowing a user 83to add notifications and then query how many notifications 84are currently being displayed via the [getActiveNotifications()][3] method. 85 86[1]: https://developer.android.com/reference/android/app/NotificationManager.html 87[2]: https://developer.android.com/reference/android/app/NotificationManager.html#notify(int, android.app.Notification) 88[3]: https://developer.android.com/reference/android/app/NotificationManager.html#getActiveNotifications() 89]]> 90 </intro> 91 </metadata> 92</sample> 93