I am trying to figure out how I should launch a notification. Creating the notification is not what I am asking, but rather a way to launch it in the background so its unobtrusive and the user can do whatever they were doing. Its for a calendar, a reminder to be exact. It is also important to note I am using AlarmManager.
-
What method should I use to run it in the background.
BroadCastReciever,Service, etc. -
Research I have found also presents a problem with
AlarmManager. When the app is killed or phone is turned off, the alarm is also. What other method should I use in order to make sure the notification is guaranteed to show for that event reminder?
If any additional info is needed please ask and I shall do so. Thanks in advance.
Create a broadcastreceiver or intentservice. Then…
If you’d like these alarms to work correctly even when the phone is restarted, then add:
as intentfilter on your Receiver in the manifest and recreate your alarms in onReceive.
EDIT
When you create a BroadcastReceiver in your application, it allows to do exactly what it sounds like: receive broadcasts in the system. So for example, you might some BroadcastReceiver like so:
To send broadcasts to this class explicitly, you define the receiver inside of the manifest, as follows:
Having this in the manifest gets you two things: You can send a broadcast explicitly to your receiver whenever you want by
Also, since you’ve told android you’d like to receive the BOOT_COMPLETED action which is broadcast by the system, your receiver will also get called when that happens.