2010-08-17 42 views
1

我試圖創建一個通知,該通知將出現在通知欄的「正在進行的」區域(如WeatherBug)中。正在進行的通知

這裏是我使用的代碼:

PendingIntent intent = PendingIntent.getActivity(lastContext, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR) 

據我瞭解,FLAG_NO_CLEAR,也應防止通知,按Clear按鈕被清除,這也是不工作

任何提示SO?

回答

5

這是因爲您在錯誤的地方使用了標誌。

你應該做的事:

notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR; 

後您創建Notification對象,並調用NotificationManager#notify

+0

之前謝謝,那沒有的伎倆! – NPike 2010-08-23 22:49:55

相關問題