2

I would like to show a notification similar to:

enter image description here

So I tried the following code:

NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);

            builder.setSmallIcon(R.drawable.ic_launcher);

            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/"));
            PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);

            builder.setContentIntent(pendingIntent);
            builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
            builder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(result));
            builder.setContentTitle(title);
            builder.setContentText(message);
            builder.setSubText("");

            NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            notificationManager.notify(2000, builder.build());

I don't get the same output there are lot of space etc marked in red.

enter image description here

So I removed builder.setContentText(message); and added everything to builder.setSubText(message); - Display was perfect with no waste space etc but here when I scroll the notification "UP" with my two fingers to make it small.. The second line in notification disappears.

Something like this:

enter image description here

if you see in the above image only title is shown, no contenttext or subtext is shown? how to solve this issue.

I am sure I am doing something wrong here? Can somebody guide me to correct this?

Thanks!

Sanjana Nair
  • 2,663
  • 6
  • 26
  • 44

0 Answers0