Actualización: estoy revisando la publicación original para compatibilidad antes de Android 3.0.¿Cómo recibir una notificación de luz LED?
Estoy tratando de crear una notificación simple y todo menos la luz funciona muy bien. Apago la pantalla cuando se activa la notificación. Usando este código obsoleto, el sonido y las vibraciones funcionan en Android 4.0 (Galaxy Nexus) y Android 2.3 (HTC EVO).
- En el HTC EVO 2.3 las luces también funcionan.
En el Galaxy Nexus 4.0, las luces no funcionan.
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;
también he intentado API nuevas que no forman parte de la biblioteca de compatibilidad v4, por lo que sólo podría probar esto en el Galaxy Nexus. La vibración y el sonido funcionan nuevamente pero no las luces.
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();
Ahora he probado esto en dos teléfonos Galaxy Nexus y la luz no funciona en ninguno de los dos. La pantalla está apagada cuando ejecuto las pruebas y todas las otras aplicaciones en los teléfonos activan las luces sin problema.
No hay luces: con este .setDefaults (Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) \t .setLights (0xff00ff00, 300, 100) – pcm2a
¿Qué tipo de teléfono? ¿Arraigado? ¿ROM personalizada? –
acciones de Galaxy Nexus y también lo he intentado con un teléfono HTC Evo Android 2.3. He vuelto a trabajar la publicación para mostrar esta información eliminada. – pcm2a