1Android NotificationChannels Sample (Kotlin)
2===================================
3
4Demonstration of using channels to categorize notifications by topic. This feature was
5            added in Android O, and allows users to have fine-grained control over their
6            notification preferences.
7
8Introduction
9------------
10
11Android O introduces notification channels to provide a unified system to help users
12manage notifications. When you target Android O, you must implement one or more
13notification channels to display notifications to your users.
14
15You can create a notification channel for each distinct type of notification you need
16to send. You can also create notification channels to reflect choices made by users of
17your app. For example, you might setup separate notification channels for each
18conversation group created by a user in a messaging app.
19
20To create a channel, call `[NotificationManager.createNotificationChannels()][1]`. You
21can then use `[Notification.Builder.setChannel()][2]` to assign your notification to that
22channel.
23
24Users can now manage most of the settings associated with notifications using a
25consistent system UI. All notifications posted to a notification channel behave the
26same. To access the settings screen, use the `ACTION_CHANNEL_NOTIFICATION_SETTINGS`
27intent:
28
29```
30Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
31intent.putExtra(Settings.EXTRA_CHANNEL_ID, mChannel.getId());
32intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName());
33startActivity(intent);
34```
35
36
37[1]: https://developer.android.com/reference/android/app/NotificationManager.html#createNotificationChannels(java.util.List<android.app.NotificationChannel>)
38[2]: https://android-dot-devsite.googleplex.com/reference/android/app/Notification.Builder.html#setChannel(java.lang.String)
39
40Pre-requisites
41--------------
42
43- Android SDK Preview O
44- Android Build Tools v25.0.3
45- Android Support Repository
46
47Screenshots
48-------------
49
50<img src="screenshots/1-main.png" height="400" alt="Screenshot"/>
51
52Getting Started
53---------------
54
55This sample uses the Gradle build system. To build this project, use the
56"gradlew build" command or use "Import Project" in Android Studio.
57
58Support
59-------
60
61- Google+ Community: https://plus.google.com/communities/105153134372062985968
62- Stack Overflow: http://stackoverflow.com/questions/tagged/android
63
64If you've found an error in this sample, please file an issue:
65https://github.com/googlesamples/android-NotificationChannels
66
67Patches are encouraged, and may be submitted by forking this project and
68submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
69
70License
71-------
72
73Copyright 2017 The Android Open Source Project, Inc.
74
75Licensed to the Apache Software Foundation (ASF) under one or more contributor
76license agreements.  See the NOTICE file distributed with this work for
77additional information regarding copyright ownership.  The ASF licenses this
78file to you under the Apache License, Version 2.0 (the "License"); you may not
79use this file except in compliance with the License.  You may obtain a copy of
80the License at
81
82http://www.apache.org/licenses/LICENSE-2.0
83
84Unless required by applicable law or agreed to in writing, software
85distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
86WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
87License for the specific language governing permissions and limitations under
88the License.
89