2013年1月1日 星期二

Android LED Notification

Notification notification = new Notification(icon, tickerText, when);
… //Do normal notification operations
//Use this if you want to use the default lights for a notification
notification.defaults |= Notification.DEFAULT_LIGHTS;
//Use this if you want custom values for the LED
notification.ledARGB = 0xff0000ff; // Blue flash
notification.ledOnMS = 300; // LED’s on for 300 ms
notification.ledOffMS = 1000; // LEDs off for 1 second
notification.flags |= Notification.FLAG_SHOW_LIGHTS;

SAMPLE:
private void RedFlashLight()
{
    NotificationManager nm = 
            ( NotificationManager ) getSystemService( NOTIFICATION_SERVICE );
    Notification notif = new Notification();
    notif.ledARGB = 0xFFff0000;
    notif.flags = Notification.FLAG_SHOW_LIGHTS;
    notif.ledOnMS = 100; 
    notif.ledOffMS = 100; 
    nm.notify(LED_NOTIFICATION_ID, notif);
}

沒有留言:

張貼留言