2. Android OS 4.4Android OS 5.2LockScreen
Notification
Augmentation of notification
Android OS 1.5 Android OS 1.6 Android OS 2.3 Heads-Up
Notification
3. Types of notification added from android version 4.1
ONE TWO THREE FOUR FIVE
Big text notification contracted & expanded.
NotificationCompat.Builder notification = new
NotificationCompat.Builder(TemplateOne.this);
notification.setStyle(new
Notification.BigTextStyle().bigText("theblogof
infinite replied...")) .build();
notification.setStyle(new Notification.InboxStyle()
.addLine("Soandso likes your post")
.addLine("Soandso reblogged your post")
.setContentTitle("3 new notes")
.setSummaryText("+3 more"))
.build();
Roll-Up NotificationsBig Picture Notifications
notification.setStyle(new
Notification.BigPictureStyle().bigPicture(mBitmap))
.build();
Action Notifications
NotificationCompat.Action visitBlog = new
NotificationCompat.Action(R.drawable.ic_person,
"Visit blog", mPendingBlogIntent);
NotificationCompat.Action follow = new
NotificationCompat.Action(R.drawable.ic_follow,
"Follow", mPendingFollowIntent);
notification.addAction(visitBlog)
.addAction(visitBlog)
.addAction(follow)
.build();
Custom Notifications
Custom Music player Notification Custom Weather Notification
5. Direct Reply
With direct reply feature in
Android N, users can quickly
respond to text message or
update the task directly
within the notification
interface.
6. Direct Reply
1. Create an instance of RemoteInput.Builder that you can add to your notification action.
2. Attach the RemoteInput object to an action using addRemoteInput().
// Key for the string that's delivered in the action's intent.
private static final String KEY_TEXT_REPLY = "key_text_reply";
String replyLabel = getResources().getString(R.string.reply_label);
RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY)
.setLabel(replyLabel)
.build();
// Create the reply action and add the remote input.
Notification.Action action =
new Notification.Action.Builder(R.drawable.ic_reply_icon,
getString(R.string.label), replyPendingIntent)
.addRemoteInput(remoteInput)
.build();
7. Direct Reply
3. Applying the action to a notification and issue the notification.
// Build the notification and add the action.
Notification newMessageNotification =
new Notification.Builder(mContext)
.setSmallIcon(R.drawable.ic_message)
.setContentTitle(getString(R.string.title))
.setContentText(getString(R.string.content))
.addAction(action))
.build();
// Issue the notification.
NotificationManager notificationManager = NotificationManager.from(mContext);
notificationManager.notify(notificationId, newMessageNotification);
8. Swipe behaviour
for notifications.
Swiping the notification
shows a gear icon behind
which can be used to make
changes to when a
notification for the app
should be fired.
11. Android Wear
Some of the visual updates and comparision between wear 1.x and wear 2.0
• Android Wear 2.0 updates the visual style of
notifications as well as introduces expanded
notifications, which provide substantial additional
content and actions in an app-like experience.
• Update touch targets of a notification.
• Dark background color.
• Updated horizontal swipe gesture on a notification
12. Expanded Notification
1. Adding additional content.
• To show additional content in your expanded notification, see Adding Pages to a
Notification.
• Additional content pages are stacked vertically in the expanded notification and
appear in the order they were added. These additional content pages can optionally
use a style such as BigTextStyle or BigPictureStyle.
2. Primary action
• The expanded notification will contain one primary action, which is the first action
in the notification unless a different action is specified using setContentAction().
3. Additional actions
• To specify additional actions, use addAction() or addActions(). The action drawer
of the expanded notification contains all available actions.
13. Smart Reply
// Create the reply action and add the remote input
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,
getString(R.string.label), replyPendingIntent)
.addRemoteInput(remoteInput)
// Allow generated replies
.setAllowGeneratedReplies(true)
.build();