android - What am I doing wrong in this alarmClock method? -


when call method first time, sets alarm @ right time(current time +2 minutes). when call method second time, doesn't set alarm @ current time +2 minutes. sets alarm @ exact same time first time. doing wrong? code:

private void setalarmnow() {     vibrator v = (vibrator) getsystemservice(context.vibrator_service);     // vibrate 500 milliseconds     v.vibrate(1000);     gregoriancalendar cal = new gregoriancalendar();      int minute = cal.get(calendar.minute)+2;     int hour = cal.get(calendar.hour_of_day);     if(minute>59){minute-=59; hour++;}       if(hour>23){hour-=23;}      intent intent = new intent(alarmclock.action_set_alarm);     intent.putextra(alarmclock.extra_hour, hour);     intent.putextra(alarmclock.extra_minutes, minute);     intent.putextra(alarmclock.extra_skip_ui, true);                  pendingintent pendingintent = pendingintent.getactivity(this, 0, intent, 0);     alarmmanager alarmmanager = (alarmmanager)getsystemservice(alarm_service);      calendar calendar = calendar.getinstance();     calendar.settimeinmillis(system.currenttimemillis());     calendar.add(calendar.second, 10);     alarmmanager.set(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), pendingintent);        log.d(tag, "backup alarm geset."); } 


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -