This Series deals with the android notifications on different types and scenarios.
This Episode consists of the following
1.Create Notification for Oreo and above
2.Create Notification for Nougat and below
5.System wide category
6.Lock Screen Visibility
The creation of android notification involves the simple understanding that we have we have to add notification channel from Oreo and above.
Why Notification Channel ?
So that we can add notification to channel and user can decide the audio and priority of the channel .
For example consider an online game app with different types of notifications such as
1.Notification to show when a friend wants to play with you .
2.Notification to show your healing is done and You are ready to play .
3.Notification from app developer asking your interest to use In-App Purchase.
Imagine all the above three is associated with different respective channels and as a user you can control the channel to show with no notification tone or don’t show at all .
Let's Create Notification Channel
Create a channel by creating the channel name , description and importance and its only for Oreo and Above
Create notification with NotificationManager and NotificationCompat.Builder
One thing to note while updating Notification is using the same NotificationID while creating it.
To cancel a notification , just pass the NotificationID
Use system wide category for Android OS about how to handle your notification in DND mode
Lock Screen Visibility
Use setVisibility() method to sow the level of Notification details in Lock screen.
You can use one of the following values
VISIBILITY_PUBLIC - shows everything
VISIBILITY_PRIVATE - shows only Notification title and icon
VISIBILITY_SECRET - will not show no information
Source Code: https://github.com/vprabhu/NotificationsDemo
Please add star if it helps you
In the next episode we will talk about Adding action button and direct reply button for Nougat and above .
Stay Hungry , Stay Foolish - YOU KNOW WHO :)