Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to have LED Light Notification?
    text
    copied!<p>Update: I am reworking the original post for compatibility before Android 3.0.</p> <p>I am trying to create a simple notification and everything but the light works great. I do have the screen off when the notification fires. Using this deprecated code sound and vibrations works on Android 4.0 (Galaxy Nexus) and Android 2.3 (HTC EVO). </p> <ul> <li>On the 2.3 HTC EVO the lights also work.</li> <li><p>On the 4.0 Galaxy Nexus the lights do not work.</p> <pre><code>Notification notification = new Notification(R.drawable.ic_launcher, "My Ticker!",System.currentTimeMillis()); notification.setLatestEventInfo(context, "My Title", "My Message", pendingIntent); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; //notification.defaults |= Notification.DEFAULT_LIGHTS; notification.ledARGB = 0xff00ff00; notification.ledOnMS = 300; notification.ledOffMS = 1000; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.flags |= Notification.FLAG_AUTO_CANCEL; </code></pre></li> </ul> <p>I have also tried newer APIs that are not part of the v4 compatibility library, so I could only test this on the Galaxy Nexus. Vibration and Sound works again but not lights.</p> <pre><code>Notification.Builder builder = new Notification.Builder(context); builder.setContentIntent(pendingIntent) .setSmallIcon(R.drawable.ic_launcher) .setTicker("My Ticker") .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.FLAG_SHOW_LIGHTS) .setLights(0xff00ff00, 300, 100) .setContentTitle("My Title 1") .setContentText("My Text 1"); Notification notification = builder.getNotification(); </code></pre> <p>I have now tested this on two stock Galaxy Nexus phones and the light works on neither. The screen IS off when I run the tests and all other apps on the phones trigger the lights without issue.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload