Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Android notifications


Published on

  • Be the first to comment

Android notifications

  1. 1. Android Notifications How not to open app and still get work done!
  2. 2. Notifications Manager Android lets you put notification into the titlebar of your app. App user can expand the notification bar and select the notification to trigger another activity. Classes Required for Notification 1. Notification 2. NotificationManager
  3. 3. Sample Code for Notification - Specify Intent //Specify which intent would be triggered if notification is selected Intent intent = new Intent(this, NotificationReceiver.class); //Specify a PendingIntent to handle notification PendingIntent pndIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
  4. 4. Actions for Notifications Common Scenarios 1. Accept/Reject(Meeting) 2. Like/Share(Social Media Post) 3. Retweet/Like(Tweet) 4. View/Purchase(Product/Service) 5. Add/Delete(Contact Request)
  5. 5. Actionable Notifications - Google Drive
  6. 6. Create Notification (e.g. Meeting Request) Notification ntfcn = new Notification.Builder(this) .setContentTitle(“New Meeting Request”) .sentContextText(“Agend”) .setSmallIcon(R.drawable.nicon) .setContentIntent(pndIntent) .setAutoCancel(true)
  7. 7. Add Actions .addAction(R.drawable.acpticon, “Accept”, pndIntent) .addAction(R.drawable.rjcticon, “Reject”, pndIntent) .addAction(R.drawable.ignrticon, “Ignore”, pndIntent).build();
  8. 8. Send Notification NotificationManager ntfcnManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0,ntfcn);
  9. 9. Expandable Notifications Android supports expandable notifications from version 4.1. You can define a big view in addition to normal notification view and it would be shown when notification is expanded. Use following three style for big view of notification big picture style, big text style and Inbox style
  10. 10. Big Picture Notification User can experience the product or service you are offering right from the notification and not required to open the app. Notification ntfcn = new Notification.Builder() //other notification class properties .setStyle(new Notification.BigPictureStyle().bigPicture(bgBit map)) .build();
  11. 11. Roll-Up Notifications Roll up notification displays multiple notifications into one. This type of notification would be used mainly for social networking apps where lots of actions are taken(interactions) and content is generated. Notification ntfcn = new Notification.Builder() ... // The same notification properties as the others .setStyle(new Notification.InboxStyle() .addLine("Letsnurture likes your post") .addLine("Letsnurture shared your post") .setContentTitle("2 new notes") .setSummaryText("+2 more")) .build();
  12. 12. Notification and Android Wear Android Wear is fast becoming second must have gadget for everyone. Note: In order to provide rich notifications like other Android Devices(Phone/Tabs) use following classes NotificationCompat, NotificationManagerCompat NotificationCompat.WearableExtender
  13. 13. Voice Input in a Notifications You can provide voice input in reply to any notification now. This is specially useful in case of wearable devices where no keyboard input is not available. Voice Input would be managed using RemoteInput class. If actions are fixed and predefined specify using a string array and populate(display) using setChoices() property of RemoteInput class
  14. 14. Setup for Voice Input and Receive It For setup of voice input add RemoteInput object to an action using addRemoteInput(). From your Bundle object receive voice input using getResutlsFromIntent. Note: Do not use Intent.getExtras() as voice input is stored as ClipData.
  15. 15. Add Pages to a Notifications Space is the biggest factor on wearable devices. Each page should have minimal details. So, You need to divide your output in pages. For this you need to use addPage() to add pages to main notification or use addPages() to add multiple pages in a Collection.
  16. 16. Stacking Notification Arrangement of is critical in case of wearable again because of space constraint. Here you can display a ‘+Number more’ e.g. +4 more so user would know how many more notification he might have to navigate through. Note: Use new setGroup() method to provide only one summary notification on wearable device.
  17. 17. Notification Settings for Android Watch Your Android watch is using the same settings you have notifications for each app on your Android Phone. 1. In case where your app makes a sound or vibrate for notifications, your watch will vibrate. 2. In case where your phone doesn’t vibrate or make a sound, your watch would display a card but won’t vibrate.
  18. 18. Custom Notifications Possibilities 1. Music Player Notification Album Art, Track Name, Artist, Previous/Play/Next Buttons 1. Weather Notification 5-Day / Hourly forecast chart with weather condition and color coding for temp. 3. To-Do list with clear option
  19. 19. Custom Notification 1. Use RemoteViews to create custom notifications 2. Use Android XML file for defining layout of Custom Notification view
  20. 20. New in Android 5.0 1. New Material Design Theme 2. Lock Screen Notification 3. Priority for Notifications (High Priority would be displayed as Heads-up Notification) 4. Cloud-Synced Notification you don’t have to dismiss same notification from multiple devices anymore.
  21. 21. Examples of Heads-up notifications 1. Message from your loved one from Whatsapp 2. Alarm when device is in use 3. System Update(e.g. Battery status indicator) 4. Incoming call or SMS while device is in use
  22. 22. General Guidelines for Notification 1. Use distinct icon(must be as unique as your app) 2. Pulse notification LED in relation to importance of notification 3. Provide notification only for events that matters to the user 4. Show current status for ongoing notifications(e.g. music player) 5. Control visibility level with PUBLIC or PRIVATE settings
  23. 23. Visit for more….