2011-12-19 96 views
0

我查找了有關如何讓android設備LED閃爍並收到關於無法將LED_NOTIFICATION_ID解析爲變量的消息的示例。我的代碼如下。有沒有人能告訴我爲什麼我收到這個錯誤?Android LED_NOTIFICATION_ID無法解析爲變量

private void redFlashLight(Context context) 
    { 
     NotificationManager nm = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); 
     Notification notif = new Notification(); 
     notif.ledARGB = 0xFFff0000; 
     notif.flags = Notification.FLAG_SHOW_LIGHTS; 
     notif.ledOnMS = 100; 
     notif.ledOffMS = 100; 
     notif.flags = Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONLY_ALERT_ONCE; 
     nm.notify(LED_NOTIFICATION_ID, notif); 
    } 

回答

2

您還沒有將LED_NOTIFICATION_ID聲明爲變量。尋找拼寫錯誤。它應該是合格的類名?

+1

基於我看到的例子,我認爲它是一個內置變量。它沒有在代碼中定義。謝謝你的幫助! – 2011-12-19 18:40:46

+0

只需使用1。 – mircobabini 2014-02-21 10:11:20