Notificationmanager.notify Creating Notifications That Are *initially* Missing Contenttext
Solution 1:
It's possible that your contentText is not displayed on devices that support big text style, and that's because you set the style to be BigTextStyle without setting the big text.
Instead of
.setStyle(new NotificationCompat.BigTextStyle())
You should try
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
This explains why on some devices you don't encounter the problem:
NotificationCompat.BigTextStyle
Helper class for generating large-format notifications that include a lot of text. If the platform does not provide large-format notifications, this method has no effect. The user will always see the normal notification view.
And this explains why on some devices you do:
public NotificationCompat.BigTextStyle bigText (CharSequence cs)
Provide the longer text to be displayed in the big form of the template in place of the content text.
Quotes taken from here.
Solution 2:
NotificationCompat.BuildermBuilder=newNotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("Event tracker")
.setContentText("Events received")
NotificationCompat.InboxStyleinboxStyle=newNotificationCompat.InboxStyle();
String[] events = newString[6];
// Sets a title for the Inbox style big view
inboxStyle.setBigContentTitle("Event tracker details:");
...
// Moves events into the big viewfor (int i=0; i < events.length; i++) {
inboxStyle.addLine(events[i]);
}
// Moves the big view style object into the notification object.
mBuilder.setStyle(inBoxStyle);
...
// Issue the notification here.
Solution 3:
Check for the msg field by keeping syso or in debugging I think it might be an empty string you are getting
(or)
Try this code surely works for you and also to display multiple notifications
NotificationCompat.Builder nBuilder;
UrialarmSound= RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
nBuilder = newNotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Kluebook - " + keys)
.setLights(Color.BLUE, 500, 500).setContentText(message)
.setAutoCancel(true).setTicker("Notification from kluebook")
.setVibrate(newlong[] { 100, 250, 100, 250, 100, 250 })
.setSound(alarmSound);
IntentresultIntent=null;
resultIntent = newIntent(context, MainLoginSignUpActivity.class);
PendingIntentresultPendingIntent= PendingIntent.getActivity(context,
notify_no, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
if (notify_no < 9) {
notify_no = notify_no + 1;
} else {
notify_no = 0;
}
nBuilder.setContentIntent(resultPendingIntent);
NotificationManagernNotifyMgr= (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);
nNotifyMgr.notify(notify_no + 2, nBuilder.build());
}
Post a Comment for "Notificationmanager.notify Creating Notifications That Are *initially* Missing Contenttext"