Android notlight not working

I am using notification to let the user now that the service is still running. Now I would like to use the highlight to remind the user. (because it's freaky)

The notification works fine, but the notification indicator does nothing. Other applications work fine with notification highlighting (gtalk, facebook).

this is more or less sample code for notifications with the 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; 

doesn't work either.

I am debugging a Galaxy Nexus with Android 4.0, but the goal of the application is Android 2.3.3.

EDIT: Could this be a resolution issue? If so, which one? I looked through everything and did not find a suitable resolution for reporting notifications.

+6
source share
2 answers

I think there is an error with the + operator, you need OR:

 notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; 

EDIT: and if you use flags, I think the correct one should be:

 notification.flags |= Notification.FLAG_SHOW_LIGHTS 
+2
source

On the jelly of the bean device, the LED only works if the notification priority is set to maximum or default, try again. The following code snippet works fine for me on jb devices.

 notification.setLights(0xFF0000FF,100,3000); notification.setPriority(Notification.PRIORITY_DEFAULT); 

Here I show the blue color for the notification, which will remain on for 100 ms and off for 3000 ms until the user unlocks his device.

And check if you use the NotificationCompat class (compatibility), than ignore the setDefaults method and use SetLight, SetSound, Setvibration, etc.

+2
source

Source: https://habr.com/ru/post/914384/


All Articles