How To Set App To Trigger Service/alarm At A Specific Time Every Day?
So I want my app to send a notification at 8:00 a.m. everyday subjected to whether there is an event on that day or not. I have a SQLlite DB which stores the dates on which notific
Solution 1:
Use Pending Intent
A pending intent is a token that you give to another application (e.g., notification manager, alarm manager or other 3rd party applications), which allows this other application to use the permissions of your application to execute a predefined piece of code.
To perform a broadcast via a pending intent, get a PendingIntent via the getBroadcast() method of the PendingIntent class. To perform an activity via a pending intent, you receive the activity via PendingIntent.getActivity().
Or
PendingIntent + Alarm Manager + Broadcast Receiver combination can work fine you have to register and unregistere broadcast receiver dynamically not in manifest. Like
publicvoidonResume()
{
IntentFilter filter = new IntentFilter();
filter.addAction("android.provider.Telephony.SMS_RECEIVED");
registerReceiver(mybroadcast, filter);
}
publicvoidonPause()
{
unregisterReceiver(mybroadcast);
}
Post a Comment for "How To Set App To Trigger Service/alarm At A Specific Time Every Day?"