2
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秒後創建。 什麼錯了?在Android的本地通知立即啓動,而不是在給定的時間
即使
.setWhen(System.currentTimeMillis()+10000)
不使其顯示10秒後。它直接顯示。