android - Alarm Manager not working -


i trying create new scheduler app runs daily on user defined time.here code below. problem scheduler not running on set time.please suggest how this

 private void setalarm(string targetcal){     toast.maketext(mainactivity.this,"alarm set", toast.length_long).show();     string[] time=targetcal.split(":");     calendar timeoff = calendar.getinstance();     intent intent = new intent(getbasecontext(), alarmreceiver.class);     pendingintent pendingintent = pendingintent.getbroadcast(getbasecontext(), rqs_1, intent, 0);     alarmmanager alarmmanager = (alarmmanager)getsystemservice(context.alarm_service);      //int days = calendar.sunday + (7 - timeoff.get(calendar.day_of_week)); // how many days until sunday     timeoff.set(calendar.hour,integer.valueof(time[0].trim()));     timeoff.set(calendar.minute,integer.valueof(time[1].trim()));     alarmmanager.setrepeating(alarmmanager.rtc_wakeup, timeoff.gettimeinmillis(), alarmmanager.interval_day , pendingintent);  } 

try code

    intent = new intent("in.servicealarmdemo.demoactivity");  /** creating pending intent */ pendingintent operation = pendingintent.getactivity(getbasecontext(), count+2, i, intent.flag_activity_new_task);  /** getting reference system service alarm_service */ alarmmanager alarmmanager = (alarmmanager) getbasecontext().getsystemservice(alarm_service); /** creating calendar object corresponding date , time set user */ gregoriancalendar calendar = new gregoriancalendar(pyear,pmonth,pday,phour,pminute);  /** converting date , time in milliseconds elapsed since epoch */ long alarm_time = calendar.gettimeinmillis();  /** setting alarm, invokes operation @ alart_time */ alarmmanager.set(alarmmanager.rtc_wakeup  , alarm_time , operation);  /** alert set */ toast.maketext(getbasecontext(), "alarm set successfully",toast.length_short).show(); 

or can try tutorial

http://wptrafficanalyzer.in/blog/setting-up-alarm-using-alarmmanager-and-waking-up-screen-and-unlocking-keypad-on-alarm-goes-off-in-android/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -