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.
Related
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.
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 a notification which I always want to stay on top.
I have already given it a priority of 2
Mostly it stays on top but, suppose there is a open WiFi network, then my notification goes down and the notification of open WiFi network comes on the top position.
But when I looked at the notification of vlc(for Android) paying a song, the notification of vlc stay on top and the notification of open WiFi network goes down.
I notification is ongoing and with priority 2.
What should I do. I am a beginner so please bear with me.
And thanks in advance.
have you tried this
NotificationCompat.Builder builder =
(NotificationCompat.Builder) new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.notify_icon)
.setContentTitle("Notification")
.setContentText("ON Top")
.setPriority(Notification.PRIORITY_MAX);
Priority Levels --> PRIORITY_MAX / PRIORITY_HIGH /PRIORITY_DEFAULT /PRIORITY_LOW /PRIORITY_MIN
read
https://material.google.com/patterns/notifications.html#correctly_set_and_manage_notification_priority
https://developer.android.com/reference/android/app/Notification.html#priority
and as StenSoft said
Android: How to create an "Ongoing" notification?
I think you can refer to this code:
Intent push = new Intent();
push.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
push.setClass(this, NotificationDemo.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, push, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationManager nm=(NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
Notification updateNotification = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_face_black_24dp)
.setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher))
.setContentTitle("Priority Max Notification Title")
.setContentText("Priority Max Notification Message")
.setAutoCancel(false)
.setDefaults(Notification.DEFAULT_SOUND)
.setPriority(Notification.PRIORITY_MAX)
.setFullScreenIntent(pi,true)
.build();
nm.notify("priorityMaxTest",2,updateNotification);
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.
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());