Как установить время, в которое уведомление будет показано ?
public int createInfoNotification(String message, Date when) {
Intent notificationIntent = new Intent(context, MainActivity.class);
NotificationCompat.Builder nb = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher_remsmed) //ic_launcher_nuffield
.setAutoCancel(true)
.setTicker(message)
.setContentText(message)
.setContentIntent(PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT))
.setWhen(when.getTime())
.setShowWhen(true)
.setContentTitle(context.getResources().getString(R.string.app_name))
.setDefaults(Notification.DEFAULT_ALL);
Notification notification = nb.getNotification();
manager.notify(lastId, notification);
notifications.put(lastId, notification);
return lastId++;
}
есть такой вот код, я честно думал что уведомление покажется в то время, которое указано методом setWhen()
у билдера.
Но уведомление почему-то показывается во время выполнения данной функции.
when.getTime()
в момент выполнения?