I created my notification like this
Notification notification = new NotificationCompat.Builder(this)
.setTicker("ticher")
.setContentTitle("title")
.setContentText("text")
.setSmallIcon(R.drawable.ic_action_email)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_disturb))
.setAutoCancel(false)
.build();
But setLargeIcon does not work. Large icon of notification is always app icon.
I don't know why. thanks for your help.
Related
How do i change notification background in android?
I am using androidx.core.app.NotificationCompat and below code work for Oreo and above Oreo device but not working for below Oreo devices.
builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pendingIntent)
.setShowWhen(false)
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setColor(ContextCompat.getColor(PlayerEngineService.this, R.color.colorBlack))
.setColorized(true);
I make custom notification View with black background. But other then notification view notification background is white.
Right it's look like this.
Thanks in Advance
You can customize all your notification UI, This will work for all device. Try these tus:
This one
Android guide
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.
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());
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());