Using LED-Based Notifications
In Chapter: System and Device Control
Author: Rachee Singh ('racheesingh')
Some Android phones are equipped with LEDs. An application can flash different color lights using the LED.
Using the NotificationManager and Notification class we can make notifications using the LED on the device.
As is in case of all notifications, we instantiate the NotificationManager class. Then we create a Notification class's object. Using the method ledARGB() we can specify the color of the LED light. The constant ledOnMS is used to specify the time in milliseconds for which the LED will be on and ledOffMS specifies the time in milliseconds for which the LED is off. The notify method starts the notification process.
Here's the code corresponding to the actions just described:
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.ledARGB = 0xff0000ff; // Blue color light flash
notification.ledOnMS = 1000; // LED is on for 1 second
notification.ledOffMS = 1000; // LED is off for 1 second
notification.flags = Notification.FLAG_SHOW_LIGHTS;