This is how i am displaying Push Notification to user.
Notification notification = new Notification.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setContentIntent(intent)
.setContentTitle("Title")
.setStyle(new Notification.BigTextStyle()
.bigText(msg))
.setSound(soundUri)
.build();
notificationManager.notify(0, notification);
This is working fine on Samsung s5, Samsung s7. But on samsung Note3 , it only displays title, and does not display message body. This may be occurring in some other devices as well.
Kindly guide me that what can be the reason of this.
Adding .setContentText(msg) to your call chain should solve the problem.
Android documentation for NotificationCompat states that "If the platform does not provide rich notification styles, [setStyle(Style style)] has no effect". I'm going to take a leap of faith and say that this is the cause of the problem.
Try this code
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setContentIntent(intent)
.setContentTitle("Title")
.setStyle(new Notification.BigTextStyle()
.bigText(msg))
.setSound(soundUri)
.setContentText(detail);
NotificationManager mNotifyMgr =
(NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.notify(mNotificationId, mBuilder.build());
Related
I am sending a notification in my app from FCM console and working fine in below android 9 devices, In the above android 9 device Time is not displayed in the notification.
below is my code -
NotificationCompat.Builder mBuilder;
mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(resultPendingIntent)
.setSound(alarmSound)
.setWhen(getTimeMilliSec(timeStamp))
.setShowWhen(true)
.setSmallIcon(smallicon)
.setContentText(message)
.setColor(colorPrimary)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setVibrate(new long[0])
.build();
After adding two-parameter to notification compact still not working -
.setWhen(getTimeMilliSec(timeStamp))
.setShowWhen(true)
Any solution?
use setStyle method,
.setStyle(NotificationCompat.BigTextStyle)
In push notification, the small icon is not showing in 7.1.1 above OS.White square like coming
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
Notification notification = mBuilder.
setSmallIcon(R.drawable.notification_icon).
setTicker("testing").setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(contentIntent)
.setSound(defaultSoundUri)
.setContentText(message)
.build();
notification.flags = Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_ID, notification);
I'm using transparent background but I'm not able to show correctly please help me.Even I follow the android icon design guidelines.
For some reason I dont get the LED on my device to show up on notifications anymore:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "myNotification")
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.logo)
.setContentTitle(msgTitle)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msgContent))
.setContentText(msgContent)
.setPriority(Notification.PRIORITY_MAX)
.setLights(Color.CYAN, 2000, 2000)
.setAutoCancel(true);
notificationManager.notify(1234, builder.build());
The notification itself is showing up correctly, it's just the LED lights not working.
Yes, my screen is off when the notifications triggers and the LED on my phone is working with other apps as well.
Here is how I do my basic Notification:
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Title")
.setContentText(msg);
mBuilder.setAutoCancel(true);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NID, mBuilder.build());
I am not using the BigViewStyle, just your basic notification. If the incoming msg is too long, it doesn't show the entire sentence. Is there anyway to do this without using BigViewStyle?
Is there anyway to do this without using BigViewStyle?
No, simply because the size of a regular Notification is limited.
I have implemented GCM PushNotification in Android and it works perfectly fine.
I even get notifications on regular basis.
I just have one query that when I get the notifications on my device tray and if I don't click it and if other notification also appears after some time then will it show two different notifications or just one i.e latest one.
Right now I am getting only the latest one.
Any help will be appreciated.
Yes you can show all notification and new one will not replace old one by passing uniqueId in mNotificationManager.notify(uniqueId, mBuilder.build())
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle("FleeGroups Notification")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.setContentText(message)
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL);
mBuilder.setContentIntent(resultPendingIntent);
mNotificationManager.notify(uniqueId, mBuilder.build());