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