anilchahal7

Notification Builder

Jun 10th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. private NotificationCompat.Builder createBaseNotification(Context context, PushData pushData, Bitmap largeIcon) throws Exception{
  2.         NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
  3.                 .setContentTitle(TextUtils.isEmpty(pushData.title) ? notificationTitle : pushData.title)
  4.                 .setSubText(pushData.pushMessageSummary)
  5.                 .setContentText(pushData.pushMessageBody)
  6.                 .setSmallIcon(R.drawable.notification_icon)
  7.                 .setColor(context.getResources().getColor(R.color.colorPrimary))
  8.                 .setLights(0, 0, 0)
  9.                 .setAutoCancel(true)
  10.                 .setDefaults(Notification.DEFAULT_ALL);
  11.  
  12.         notificationBuilder.setContentIntent(getPendingIntent(context, pushData.pushDeeplink, pushData.pushId));
  13.         if(largeIcon != null) {
  14.             notificationBuilder.setLargeIcon(largeIcon);
  15.         }
  16.         return notificationBuilder;
  17.     }
Add Comment
Please, Sign In to add comment