我正在尝试使用Android的通知管理器创建通知,但关键是我希望通知在未来30天内显示。我的代码如下:
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);
然而,通知仍然立即显示出来。据我所读,“when”参数只用于在状态栏中排序通知的Notification构造函数中。有没有办法让通知在未来的某个日期/时间显示?提前谢谢。