NotificationManager

Class to notify the user of events that happen. This is how you tell
the user that something has happened in the background.

Notifications can take different forms:

A persistent icon that goes in the status bar and is accessible
through the launcher, (when the user selects it, a designated Intent
can be launched),

Turning on or flashing LEDs on the device, or

Alerting the user by flashing the backlight, playing a sound,
or vibrating.

Each of the notify methods takes an int id parameter and optionally a
String tag parameter, which may be null. These parameters
are used to form a pair (tag, id), or (null, id) if tag is
unspecified. This pair identifies this notification from your app to the
system, so that pair should be unique within your app. If you call one
of the notify methods with a (tag, id) pair that is currently active and
a new set of notification parameters, it will be updated. For example,
if you pass a new status bar icon, the old icon in the status bar will
be replaced with the new one. This is also the same tag and id you pass
to the cancel(int) or cancel(String, int) method to clear
this notification.

Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

IMPORTANCE_MAX

IMPORTANCE_MIN

Min notification importance: only shows in the shade, below the fold. This should
not be used with Service.startForeground
since a foreground service is supposed to be something the user cares about so it does
not make semantic sense to mark its notification as minimum importance. If you do this
as of Android version O, the system will show
a higher-priority notification about your app running in the background.

createNotificationChannel

Creates a notification channel that notifications can be posted to.
This can also be used to restore a deleted channel and to update an existing channel's
name, description, and/or importance.

The name and description should only be changed if the locale changes
or in response to the user renaming this channel. For example, if a user has a channel
named 'John Doe' that represents messages from a 'John Doe', and 'John Doe' changes his name
to 'John Smith,' the channel can be renamed to match.

The importance of an existing channel will only be changed if the new importance is lower
than the current value and the user has not altered any settings on this channel.
All other fields are ignored for channels that already exist.

Parameters

channel

NotificationChannel: the channel to create. Note that the created channel may differ from this
value. If the provided channel is malformed, a RemoteException will be
thrown.

createNotificationChannelGroup

Creates a group container for NotificationChannel objects.
This can be used to rename an existing group.

Group information is only used for presentation, not for behavior. Groups are optional
for channels, and you can have a mix of channels that belong to groups and channels
that do not.

For example, if your application supports multiple accounts, and those accounts will
have similar channels, you can create a group for each account with account specific
labels instead of appending account information to each channel's label.

notify

Post a notification to be shown in the status bar. If a notification with
the same id has already been posted by your application and has not yet been canceled, it
will be replaced by the updated information.

Parameters

id

int: An identifier for this notification unique within your
application.

notification

Notification: A Notification object describing what to show the user. Must not
be null.

notify

Post a notification to be shown in the status bar. If a notification with
the same tag and id has already been posted by your application and has not yet been
canceled, it will be replaced by the updated information.

Parameters

tag

String: A string identifier for this notification. May be null.

id

int: An identifier for this notification. The pair (tag, id) must be unique
within your application.

notification

Notification: A Notification object describing what to
show the user. Must not be null.