Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification multiline

How to make a long notification multiline. I am using the below code snippet but its not working:

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)   .setContentTitle(title)   .setSmallIcon(R.drawable.icon)   .setStyle(new NotificationCompat.BigTextStyle().bigText(message))   .setContentText(message)   .setContentIntent(pIntent);  return mBuilder.build(); 
like image 508
teja Avatar asked Nov 06 '13 07:11

teja


People also ask

How do I show multiple notifications on Android?

Set the unique id to let Notification Manager knows this is a another notification instead of same notification. If you use the same unique Id for each notification, the Notification Manager will assume that is same notification and would replace the previous notification.

How do you extend notifications?

To expand a notification, tap the Down arrow . Then, to act directly from a notification, tap an action, like Reply or Archive. Some apps show a dot when you get a notification. Touch and hold the app with the dot to see the oldest notification.

How can you make a list of notifications into a group notification?

Grouped notifications must have an extra notification which acts as the group summary. To enable grouped notifications, you must set a group summary. This group summary should include some of the text from each of the other notifications in the group, to help the user understand what is in the group.


2 Answers

Add this :

NotificationCompat.Builder builder = new NotificationCompat.Builder(             context);     Notification notification = builder.setContentIntent(contentIntent)             .setSmallIcon(icon).setTicker(appname).setWhen(0)             .setAutoCancel(true).setContentTitle(appname)             .setStyle(new NotificationCompat.BigTextStyle().bigText(message))             .setContentText(message).build();      notificationManager.notify(0, notification); 

Also check : Multiline Notification

like image 77
Siddharth_Vyas Avatar answered Sep 21 '22 05:09

Siddharth_Vyas


Bitmap icon1 = BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);       NotificationCompat.Builder builder = new NotificationCompat.Builder(this)             .setSmallIcon(getNotificationIcon()).setLargeIcon(icon1)             .setTicker(title)             .setContentTitle(title)             .setContentText(message)             .setAutoCancel(true)             .setTicker(message)             .setStyle(new NotificationCompat.BigTextStyle().bigText(title))             .setStyle(new NotificationCompat.BigTextStyle().bigText(message))             .setPriority(Notification.PRIORITY_MAX)             .setContentIntent(pIntent)             .setContent(remoteViews)              .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))             .setVibrate(new long[] {1, 1, 1})              .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher))             .setDefaults(Notification.DEFAULT_SOUND)             .setDefaults(Notification.DEFAULT_ALL);     NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);     Notification notify = new Notification();     notify.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONLY_ALERT_ONCE;     Random random = new Random();     notificationmanager.notify(random.nextInt(), builder.build()); 
like image 24
Dhiraj Kumar Avatar answered Sep 20 '22 05:09

Dhiraj Kumar