android - Alarm Manager Not Firing -


in code interval ( third parameter) on setrepeating() method seems not firing every 5 sec .

it keeps increasing in time, it's first 1 or 2 in time others fires after 40+secs

so what's wrong here?

public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      intent = new intent(this, mainactivity2activity.class);     i.setflags(intent.flag_activity_new_task);     pendingintent pi = pendingintent.getactivity(this, 0, i, pendingintent.flag_cancel_current);     alarmmanager = (alarmmanager) getsystemservice(context.alarm_service );     am.setrepeating(rtc_wakeup,system.currenttimemillis(),1000*5,pi);       }    } 

take here: http://developer.android.com/reference/android/app/alarmmanager.html#setrepeating(int, long, long, android.app.pendingintent)

as you're firing alarm every 5 seconds:

note: timing operations (ticks, timeouts, etc) easier , more efficient use handler.

your code ok. explanation of delay you're experiencing may be:

note: of api 19, repeating alarms inexact. if application needs precise delivery times must use one-time exact alarms, rescheduling each time described above. legacy applications targetsdkversion earlier api 19 continue have of alarms, including repeating alarms, treated exact.

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -