0
我有一個NotificationManager
,成功地創建了一個Notification
:NotificationManager.notify拋出:IllegalArgumentException -
private void showNotification() {
Notification notification = new Notification(R.drawable.snog_icon, getString(R.string.sn_g_entering_beacon_mode_),
System.currentTimeMillis());
// The PendingIntent to launch our activity if the user selects this notification
Intent i = new Intent(this, SnogActivity.class);
i.putExtra("fromNotification", "yes");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, 0);
notification.setLatestEventInfo(this, getString(R.string.sn_g_avalanche_buddy),
getString(R.string.beacon_mode_activated_), contentIntent);
notification.flags |= Notification.FLAG_ONGOING_EVENT; // Notification.DEFAULT_ALL
// Send the notification.
// We use a string id because it is a unique number. We use it later to cancel.
mNM.notify(R.string.service_started, notification);
}
這部分工作正常,就說明我的通知,如果我點擊該通知的正確的活動開始。後來在我的應用程序試圖通知一個簡單的通知:
Notification not = new Notification(R.drawable.snog_icon, "checker", System.currentTimeMillis());
not.flags |= Notification.DEFAULT_ALL;
mNM.notify(R.string.checker, not);
這崩潰的應用程序中調用notify()
用IllegalArgumentException
。根據相當多的互聯網結果,我應該使用NotificationCompat.Builder
,但這根本不可用。
在我的Eclipse安裝中必須非常麻煩,它不會加載支持庫.... –
試圖在SDK管理器中找到它:什麼都沒有,在SDK文件夾中:什麼都沒有。 –
需要再次更新一切,那裏是... :) –