0

Well I have an alarm that should be called every day, but its not working. if I set it every minute it works, same for every hour. Here's my alarm call:

    try {
         Calendar cal = Calendar.getInstance();
         cal.add(Calendar.MILLISECOND, 1);
         Intent intent = new Intent(this, AlarmReceiver.class);
         intent.putExtra("alarm_toast", "Working");
         PendingIntent sender = PendingIntent.getBroadcast(this, 092809, intent, PendingIntent.FLAG_UPDATE_CURRENT);

         AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
         am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 3600000*3, sender);
    } catch (Exception e1) {
        e1.printStackTrace();
    }

I have even hard coded the launching time, (currently testing it for 3600000*3 = 3 hours), but it also don't work for every day. What am I doing wrong?

Rotary Heart
  • 1,899
  • 3
  • 29
  • 44
  • Alarms are not saved if you turn your device off, do you? – Evos Dec 07 '12 at 05:37
  • No I didn't, also there's any way to get the alarm back? didn't know that it will not get saved – Rotary Heart Dec 07 '12 at 05:38
  • Did you try other variants of alarms? For example, you can try this scenario: `to use one-time alarms, scheduling the next one yourself when handling each alarm delivery.` EDIT: also you can try to set `wake-lock` for the time while your `BroadcastReceiver` perform its work – Evos Dec 07 '12 at 05:48

1 Answers1

0

Please check this thread. you may get solution.

Community
  • 1
  • 1
Sharmilee
  • 1,286
  • 1
  • 12
  • 20