我試圖使用Android的通知管理器創建通知,但是,訣竅是我希望通知在未來30天內顯示。在我的代碼我這樣做:Android延遲通知
Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
long when = System.currentTimeMillis() + (30 * 24 * 3600 * 1000);
Notification notification = new Notification(R.drawable.some_image, "A title", when);
notification.setLatestEventInfo(getApplicationContext(), "You're late", "Some description", contentIntent);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(NOTIFY_ATTEND_ID, notification);
但是,該通知仍呈現瞬間可達。從我讀的內容來看,Notification構造函數的「when」參數僅用於對StatusBar中的通知進行排序。無論如何要在以後的日期/時間顯示通知嗎?提前致謝。
將它展現在未來30天不是微不足道的。警報等在啓動時死亡。你必須保持服務或東西 – Falmarri 2010-11-03 06:05:19