android - Alarm Manage Issue -


my app has repeating tasks running every 5-minutes. try install same app twice , alarm manager don't fire broadcast doing task.

first time install working time, until reinstall same version stop repeating task. problem alarm manager. don't it.

this code:

     intent intent = new intent(context, checkingpricereceiver.class);     intent.setaction("com.abccompany.trading");      pendingintent pendingintent = pendingintent.getbroadcast(context,      req_code, intent, pendingintent.flag_update_current);      long minterval = 300000;     long triggertime = system.currenttimemillis() + minterval;      alarmmanager alarmmanager = (alarmmanager)      context.getsystemservice(context.alarm_service);      alarmmanager.setrepeating(alarmmanager.rtc_wakeup, triggertime, minterval, pendingintent); 

i don't know how fix it. please help!!~~

from answer, android alarm difference between 4 types of alarm alarmmanager provides , when use what?

also tells difference in types of alarms, https://developer.android.com/training/scheduling/alarms.html

elapsed_realtime

it trigger since boot time. if set 300000 alarm trigger every 5 minutes , not take current time in consideration.

rtc

it trigger per clock time meaning not take boot time in consideration , trigger @ time specified.

to wake device use this,

alarmmanager.setrepeating(alarmmanager.elapsed_realtime_wakeup, triggertime, minterval, pendingintent); 

else use if don't want wake device

alarmmanager.setrepeating(alarmmanager.elapsed_realtime, triggertime, minterval, pendingintent); 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -