I am trying to invoke certain function in my app at specific time every week. Here is what I did:
In my activity I have following code
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
PendingIntent pIntent;
//my function to get first invoke time
long lAlarmStartTime = getAlarmStartTime(Calendar.SUNDAY, alrm);
Intent intentArg = new Intent(getApplicationContext(), RcvAlarms.class).putExtra (ALARM_ALARM_ID, alrm.getMy_id());
pIntent = PendingIntent.getActivity(getApplicationContext(),
(int) task.getMy_id() * 10 + Calendar.SUNDAY,
intentArg, flag);
am.setRepeating(AlarmManager.RTC_WAKEUP, lAlarmStartTime,
AlarmManager.INTERVAL_DAY * 7, pIntent);
I have another another class:
public class RcvAlarms extends BroadcastReceiver {
public RcvAlarms() {
// TODO Auto-generated constructor stub
}
@Override
public void onReceive(Context context, Intent intent) {//my job }
My manifest has the following receiver tag inside the application tag:
<receiver android:name=".RcvAlarms" android.text="Repeat Task Receiver"></receiver>
Could someone please tell me why onReceive
is not getting invoked when my device time reaches start time?