我正在尝试使用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);
Run Code Online (Sandbox Code Playgroud)
但是,通知仍然会立即显示.根据我的阅读,Notification构造函数的"when"参数仅用于对StatusBar中的通知进行排序.无论如何要在未来的日期/时间显示通知吗?提前致谢.
android ×1