long when = Calendar.getInstance().getTimeInMillis();
when += 10000;
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
getApplicationContext())
.setWhen(when)
.setContentText(notificationContent)
.setContentTitle(notificationTitle)
.setSmallIcon(smalIcon)
.setAutoCancel(true)
.setTicker(notificationTitle)
.setLargeIcon(largeIcon)
.setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_VIBRATE| Notification.DEFAULT_SOUND)
.setContentIntent(pendingIntent);
这在 onCreate 中运行,但是,我的通知会在应用程序启动时立即创建,而不是在 10 秒后创建。怎么了 ?
甚至
.setWhen(System.currentTimeMillis()+10000)
10 秒后不显示。它直接显示。