15
Notifications

Android Notifications in Android Nougat 7.0

Embed Size (px)

Citation preview

Page 1: Android Notifications in Android Nougat 7.0

Notifications

Page 2: Android Notifications in Android Nougat 7.0

Android OS 4.4Android OS 5.2LockScreenNotification

Augmentation of notification

Android OS 1.5 Android OS 1.6 Android OS 2.3 Heads-UpNotification

Page 3: Android Notifications in Android Nougat 7.0

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("theblogofinfinite 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

Page 4: Android Notifications in Android Nougat 7.0

Android Nougat

Notifications

Page 5: Android Notifications in Android Nougat 7.0

Direct ReplyWith direct reply feature in Android N, users can quickly respond to text message or update the task directly within the notification interface.

Page 6: Android Notifications in Android Nougat 7.0

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();

Page 7: Android Notifications in Android Nougat 7.0

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);

Page 8: Android Notifications in Android Nougat 7.0

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.

Page 9: Android Notifications in Android Nougat 7.0
Page 10: Android Notifications in Android Nougat 7.0

Android WearNotifications

Page 11: Android Notifications in Android Nougat 7.0

Android WearSome 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

Page 12: Android Notifications in Android Nougat 7.0

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.

Page 13: Android Notifications in Android Nougat 7.0

Smart Reply

// Create the reply action and add the remote inputNotificationCompat.Action action =new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,getString(R.string.label), replyPendingIntent).addRemoteInput(remoteInput)

// Allow generated replies.setAllowGeneratedReplies(true).build();

Page 14: Android Notifications in Android Nougat 7.0

References

• https://www.objc.io/issues/11-android/android-notifications/

• http://www.androidcentral.com/whats-new-android-n

• https://developer.android.com/preview/features/notification-updates.html

• https://www.youtube.com/watch?v=-iog_fmm6mE

Page 15: Android Notifications in Android Nougat 7.0

Queries ??Thank You Pankaj Lilan

Android Developer @ Gracia Marcom

[email protected]

www.pankajlilan.com

@PankajLilan