创建通知时遇到问题。 我必须在事件发生前一天创建一个通知。但是,通知会在事件发生后立即显示。 正确设置了setWhen()和setShowWhen()。
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
mBuilder.setSmallIcon(R.drawable.icon)
.setContentTitle("Event")
.setContentText(heritage.getTitle())
.setSubText("Tap to see event")
.setShowWhen(true)
.setContentIntent(pendingIntent)
.setWhen(setDateNotification(startDate, time))
.setAutoCancel(true);
NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyMgr.notify(1, mBuilder.build());