我在我的應用程序中遇到了通知圖標的一個奇怪問題。Android開發通知圖標問題
我的應用程序通過藍牙發送和接收數據。當應用程序啓動時,它會創建應用程序(icon.png)的通知圖標。然後它會看到沒有藍牙設備連接並將圖標更改爲(warn.png)。問題是,當頂部的狀態欄顯示warn.png時,在正在進行的通知下拉菜單中,它具有原始圖標(icon.png)和文本「無藍牙設備已連接」。當藍牙設備連接時,狀態欄圖標變回原始圖標(icon.png),但在正在進行的通知中,它具有帶有「連接建立」消息的警告圖標。
下面是我使用的代碼:
private void notification_updates(String DISPLAY_TEXT, String ONGOING_TEXT, int ICON) {
Intent intent = new Intent(this,GUI.class);
intent.addFlags(intent.FLAG_ACTIVITY_NEW_TASK | intent.FLAG_ACTIVITY_SINGLE_TOP);
try
{
notification.setLatestEventInfo(Monitor.this, "App_Name",ONGOING_TEXT,
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
notification.icon = ICON;
notification.tickerText = DISPLAY_TEXT;
notification.flags = notification.FLAG_ONGOING_EVENT; //on going events
notification.flags += notification.FLAG_NO_CLEAR; //no clear.
mManager.notify(APP_ID, notification);
} catch(Exception e)
{
Log.e(TAG, "Failed to Notifiy the notification manager (create):\n" + e.toString());
}
}
添加通知通知=新通知(ICON,ONGOING_TEXT,System.currentTimeMillis());照顧它。 – jinanwow 2011-01-11 22:07:08