我目前正在嘗試測試我的代碼,以確保正確設置通知。我這樣做的方式是設置3個不同的警報,分別顯示一個通知。但問題是,1有效,但我從來沒有看到其他兩個。我的代碼:您允許進行多少次Android通知?
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
Notification.Builder builder = new Notification.Builder(context)
.setTicker(intent.getStringExtra("event")+"-"+intent.getStringExtra("location"))
.setWhen(System.currentTimeMillis())
.setContentTitle(intent.getStringExtra("event"))
.setContentText(intent.getStringExtra("time_start")+"-"+intent.getStringExtra("location"))
.setSmallIcon(R.drawable.ic_launcher);
Notification notification = builder.getNotification();
mNotificationManager.notify(intent.getIntExtra("id", 0),notification);
的「ID」,也就是在它得到的數字遞增的意圖多餘的,所以像1,2,3,我使用AlarmManager
設置報警。我認爲只要notify
中的第一個參數是唯一的,它就會顯示通知,但它還沒有。這有什麼理由?提前致謝。
我記得有類似的問題,答案[這裏] [1]可能會有所幫助。 [1]:http://stackoverflow.com/questions/6192569/android-notification-callback – NoBugs 2012-07-11 05:44:42
嗯,我看了看你說的話和醫生,這是有道理我猜! Ima試試吧 – Andy 2012-07-11 05:54:16
仍然沒有工作。我改變了你提到的方式,但我的問題依然存在。 – Andy 2012-07-11 05:58:38