У меня есть публичный класс для отправки уведомлений ...
public class notifyHelper {
public void sendNotification(Activity caller, Class<?> activityToLaunch, String title, String msg, int numberOfEvents, boolean flashLed, boolean vibrate, int ID) {
NotificationManager notifier = (NotificationManager) caller.getSystemService(Context.NOTIFICATION_SERVICE);
// Create this outside the button so we can increment the number drawn over the notification icon.
// This indicates the number of alerts for this event.
long whenTo = System.currentTimeMillis() + (1000 * 60 * 15);
final Notification notify = new Notification(R.drawable.icon, "", whenTo);
notify.icon = R.drawable.icon;
notify.tickerText = "TV Spored ++";
notify.when = whenTo;
notify.number = numberOfEvents;
notify.flags |= Notification.FLAG_AUTO_CANCEL;
if (flashLed) {
// add lights
notify.flags |= Notification.FLAG_SHOW_LIGHTS;
notify.ledARGB = Color.CYAN;
notify.ledOnMS = 500;
notify.ledOffMS = 500;
notify.defaults |= Notification.DEFAULT_SOUND;
}
if (vibrate) {
notify.vibrate = new long[] {100, 200, 200, 200, 200, 200, 1000, 200, 200, 200, 1000, 200};
}
Intent toLaunch = new Intent(caller, activityToLaunch);
PendingIntent intentBack = PendingIntent.getActivity(caller, 0, toLaunch, 0);
notify.setLatestEventInfo(caller, title, msg, intentBack);
notifier.notify(ID, notify);
}
public static void clear(Activity caller) {
NotificationManager notifier = (NotificationManager) caller.getSystemService(Context.NOTIFICATION_SERVICE);
notifier.cancelAll();
}
}
Независимо от того, что я делаю (посмотрите когда), это уведомление всегда отображается при вызове ... Как я могу установить время уведомления?
Спасибо за ответ!