Skip to content Skip to sidebar Skip to footer

Android Alarm Manager And Broadcastreceiver

Im trying to set an alarm that will send an intent to a broadcast receiver. The reciever should then print a line in the logcat stating it has worked. However I'm getting no indica

Solution 1:

This math seems wrong. I believe you are trying to set an alarm that won't go off for a few generations:

long currentTimeMillis = System.currentTimeMillis();
long nextUpdateTimeMillis = currentTimeMillis * DateUtils.MINUTE_IN_MILLIS;

Maybe you meant for the alarm to go off in one minute:

long nextUpdateTimeMillis = currentTimeMillis + DateUtils.MINUTE_IN_MILLIS;

Anyway first use:

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 
                          System.currentTimeMillis() + 10000, 
                          5000,
                          pendingIntent);

To confirm your setup is correct, if so you need to recalculate your nextUpdateTimeMillis.

Post a Comment for "Android Alarm Manager And Broadcastreceiver"