With this newer version of Android, users can access more controls over notifications. Android Oreo users can change any of the settings for any of the notification channel which is there on their device. The best part is that you can now bifurcate notification of the app into different channels. All the notifications which are inserted in the same channel have similar behavior. You can create a different channel for notifications that are urgent. These notifications will be received by an alert sound or notification light or vibration and then set a quieter channel for the rest of your app notification.
Notification channels are a great relief for the Android users and they have a lot to offer. For Android app development companies, there is a better reason to install notification channel: they don’t have a choice! If your app is targeting Android 8.0 and you try posting a notification without assigning it to any notification channel, then no notification will be displayed to the user. So, being a developer, if you don’t want your app to miss on this new feature, here’s how to create notification channel while building Android Oreo app.
Set the Development Environment
Before initiating the development for Oreo, make sure you have following things installed:
- Android O SDK
- Android Studio 3.0 Beta
- Android Emulator 26.1.4.
- SDK Build Tools 26.0.1
- SDK Platform Tools 26.0.0
If your Android device isn’t updated to the Android 8.0, then you will have to create an AVD (Android Virtual Device). Choose Tools, go to Android and then Choose AVD manager by using the Android Studio Toolbar. Click on the ‘create virtual device’ option and then choose Oreo API level 26 for your system image.
Create the Layout of the App
Well, here we are learning the process of installing notification channel. So, here we are going to create two channels and assign them some settings. While you are building your own app, there are certain considerations to be taken care of. Type of notification your app can generate, how to group these notifications, and the behavior of each and every type of notification are the things you need to consider. Creating more channels entails the users with more options for customization. Well, make sure you don’t give excessive options as this might confuse the users. Here are some of the UI elements for the layout.
- A post notification tab to help the users to post a new notification when they want to.
- An Edit text tab to enable the users to type a text and enter in the notification channel.
- Settings option to help the users to make any changes as per their like and convenience.
Build the Notification Channel
The intuitive step you need to take while inserting notification channel is to build a channel object and assign it the following things.
- An ID which must be unique.
- Name of the channel which will be displayed on the channel’s setting screen.
- Priority setting: You cannot give importance to the individual notification. You will have to set priority on which notification is most important and which one is least important. This will be applicable to the entire bunch of notifications entering to this channel.
You can set the default behavior of the of your notification channel which will also display a notification dot on supported launchers.
Assign Notification to Each Channel
If Android Oreo is the target of your app then you must choose a notification channel every single time you create a notification by assigning the channel’s ID to each notification. The setChannelld method is one of the alternate methods to assign notification. Whenever any app intends to send notification without assigning the channel, it won’t directly appear on the screen. Instead, an error will be detected and will suggest to assign the channel first and then send the notification.
Add Notification Icon
To depict the clear distinction between the notification channel, different icons for different channels must be set. The best ways to create icons is to make use of Android Studio image Asset studio. Choose different icons and assign them to the notification channels.
Run the App and Test it
When done with every step, don’t feel that you are done. Run the app and test it to check whether it functions properly and is bug-free. Attach an Android device to the Android app development machine and then run the app from the Android Studio toolbar. Check whether the app is loading properly, try adding text and posting notification in various channels.