Skip to content Skip to sidebar Skip to footer

Is It Possible To Set An Android Notification Or A Later Date And Time That Will Fire When The App Is Not Running?

From what I have read it seems that code like this would require the app to be running in a thread until the notification fires. I need the notification to fire at a later date and

Solution 1:

As A--C wrote, use AlarmManager to schedule a PendingIntent to be invoked at your desired time. You will probably use an RTC_WAKEUP alarm, meaning "the time is based on System.currentTimeMillis(), like Calendar uses" and "let's wake up the device out of sleep mode". Use a broadcast PendingIntent, and your Notification code can go into the onReceive() method, if you do not need to do any disk or network I/O to get the information to use for the Notification itself.

Note that in Android 4.4 the rules for AlarmManager changed a bit. You will want to use setExact() on Android 4.4+ and set() on earlier Android versions.

Post a Comment for "Is It Possible To Set An Android Notification Or A Later Date And Time That Will Fire When The App Is Not Running?"