You are on page 1of 12

INTRODUCING

NOTIFICATIONS
Configuring
Notifications
• NotificationManager is available to
you through your application via
the passing of an appropriately
structured parameter to a
getSystemService() method call.
This can be as simple as the
following code snippet:
getSystemService(NOTIFICATIO
N_SERVICE)
Configuring
Notifications (cont.)
Some of the most common
methods you will use with
the NotificationManager
object are:
1. notify()
2. cancel()
3. cancelAll()
Adding Sounds to Your Notification

Notification myNotification = new Notification(...);


myNotification.defaults = Notification.DEFAULT_SOUND;

An example of using the stock Android “Kalimba” sound is shown in the


following, using the Uri for this resource via the ContentResolver class
and assigning the sound accordingly: Notification myNotification = new
Notificiation(...); myNotification.sound =
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
getPackageName() + "/raw/kalimba");
The built-in light for an Android device can be
controlled in several ways by configuring based on
Using your Notification object’s configuration:

Device The .lights( ) method activates the LED when passed a


Boolean TRUE value.

Lights for You can change the color of the LED, on supported
devices, via the ledARGB parameter and the matching
Your hex code for the RGB-based color you wish to use.

Notification Blink and cycle the light using the ledOnMS and
ledOffMS values, expressing on and off times in
milliseconds.
Icon Sizes for Adding icons allows you to tailor
icons to your desired level of
Different Android artistry, but there are
considerations for the various
Versions versions of Android you need to
keep in mind, as these affect the
resolution of icon images
supported.
To maximize the range of Android
devices you can support and their
related notification styles and sizes,
you should create at least four
drawables representing your icon:
A 12-pixel by 19-pixel bounding box,
Icon Sizes housing a 12-pixel square icon
for A 16-pixel by 25-pixel bounding box,
Different housing a 16-pixel square icon

Android A 24-pixel by 38-pixel bounding box,


housing a 24-pixel square icon
Versions
(cont.) A 25-pixel square
NOTIFICATIONS
IN ACTION
Supporting Logic to Create the Notifications
Supporting Logic to Create the Notifications
(cont.)
Supporting Logic to
Create the
Notifications (cont.)
Then we get into the meat of using
the myNotifyBuilder object, adding
lots of notification bells and whistles
for the final Notification object we will
build:
• .setTicker( )
• .setNumber( )
• .setSound( )
• .setVibrate( )
• .setAutoCancel( )
THANK YOU AND
GODBLESS !! ☺ ☺

You might also like