I'm using a notification to let the user now that the service is still running. Now I'd like to use the notificationlight to remind the user. (because it's fancy)
The notification works fine, but the notification light does nothing. Other applications work fine with the notification light, (gtalk, facebook)
it's more or less the example code for notifications with addition of these flags:
notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 100;
notification.ledOffMS = 100;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.flags |= Notification.FLAG_NO_CLEAR + Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(NOTIFICATION_ID, notification);
and
notification.defaults |= Notification.DEFAULT_LIGHTS;
instead doesn't work either.
I'm debugging on a Galaxy Nexus with Android 4.0, but the app's target is Android 2.3.3
EDIT: could this be a problem of permission? If yes, which one? I looked through all and found no matching permission for the notification light.
I think there is an error with the + operator, you need the OR:
notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
EDIT: and if you are using flags, I think the right one should be:
notification.flags |= Notification.FLAG_SHOW_LIGHTS
On jelly bean devices, led only works if notification priority is set to max or default, please check again. Following snippet of code is working fine for me on jb devices.
notification.setLights(0xFF0000FF,100,3000);
notification.setPriority(Notification.PRIORITY_DEFAULT);
Here I'm showing blue color led for notification which will remain on for 100 ms and off for 3000 ms till user unlocks his device.
And check if you are using NotificationCompat (compatibility) class than ignore setDefaults method and use SetLight, SetSound, Setvibration, etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With