IAN LAKE: Remember back when dinosaurs ruled the earth,
and Android notifications looked like this?
Oh my.
Thankfully, I've seen fewer dinosaurs around.
And Android notifications have gotten a lot better.
Ever-evolving APIs don't always make for the easiest
development experience.
And that's why there's NotificationCompat.
It gives you a single interface across all API levels,
so you can concentrate on building
the best notifications you can.
I'm Ian Lake.
And I'll show you how you can build awesome notifications
with the help of NotificationCompat,
helping reengage users whether they're on their phone, watch,
or in their car.
But I'm getting ahead of myself.
Let's start at the beginning.
Every notification has a few required parts-- a small icon,
title, and text.
To build a notification, use a NotificationCompat builder.
Then build and send the notification.
Done.
One fatal flaw.
Tapping on this notification does nothing.
Nothing!
We need a content intent that points
to the activity we want to launch when
the user taps the notification.
But we can do so much more with notifications.
Set a color, to make the notification
recognizable as from your app.
Set a large icon, and now we actually know
who the notification is from.
Already you have something you might actually
want to click on.
This compact title and text format is the basic.
And all of it's available on older platforms.
But basic shouldn't be where you stop.
Let's make this good.
Like, really good.
On Android 4.1 and higher devices,
notifications can expand, giving you
more space to work with, going beyond the title and one
line of text.
NotificationCompat provides four styles.
Which you can use to improve your notifications,
particularly when expanded.
You'll find BigTextStyle for showing multiple lines of text,
such as a long message, perfect to actually see
the full message.
InboxStyle, for showing a list of single line strings.
BigPictureStyle for showing a-- you
guessed it-- a big picture when expanded.
And MediaStyle, for adding media controls directly
to your notification.
Well, now our notification has some room to breathe
and gives users a lot of information,
pulling them back into your app.
Good.
But we're busy people.
Adding actions to your notification
gives users quick access to the most important actions,
without breaking their groove.
Not that I'd ever mute Joanna.
But notifications aren't just on your mobile device anymore.
They're also on your wrist, with Android Wear.
Any actions you've added to your notification
are automatically mirrored over to Android Wear devices,
enabling users to handle tasks without even pulling out
their phone or opening the app.
But mirroring your phone experience over to Android Wear
can only get you so far.
To really make things great, you can use NotificationCompat's
WearableExtender.
Here's where all the Wear-specific magic happens.
We've talked about mirroring actions.
With WearableExtender, you can build
the perfect set of actions that makes sense for the watch.
Including voice replies.
Again, rich actions that increase engagement, even when
the user can't open your app.
Another example is adding a high resolution background
image, the easy way to offer a literally crisp experience.
There's a lot more NotificationCompat's
WearableExtender gives you though,
including adding additional pages of information
to the notification for extra content and the ability
to group notifications together into a stack,
giving you all the details on the watch,
but a summary notification on the phone.
OK, so there's a lot you can do on your wrist.
What about an Android Auto equipped car?
Here, messaging apps can use NotificationCompat's
CarExtender to send a message, or a whole set of messages,
in a conversation to Android Auto, where
they can be read aloud and the user can voice reply,
all while keeping their eyes on the road.
So, using NotificationCompat, you
get a single API for all Android versions, support
for progressive enhancements through adding
styles and actions, and even the tools
to bring great notifications to Android Wear and Android Auto.
That's a lot of opportunity to make beautiful notifications
everywhere.
Get started with NotificationCompat
by adding the support library to your project.
You'll need App Compat for media style notifications,
or just support v4 for everything
else NotificationCompat has to offer.
With the tools you need to build great notifications
on a phone, tablet, watch, and car, you can't help but build
better apps.
[MUSIC PLAYING]