tags:

views:

28

answers:

0

Hello everyone, could you please have a look at this

if(current.getTimeInMillis() < cal.getTimeInMillis()){
      //current.add(Calendar.MINUTE, 15);
      alarms.setRepeating(AlarmManager.RTC_WAKEUP, current.getTimeInMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, alarmIntent);
      Toast.makeText(this, "Alarm will go of 15mins from now", Toast.LENGTH_SHORT).show();

     }else {
       alarms.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent);
       Toast.makeText(this, "Alarm set in " + cal.getTimeInMillis() + " seconds",
         Toast.LENGTH_LONG).show();
     }

current.getTimeInMillis() is the system time and cal.getTimeInMillis() is a set time that i want an event to occur. i am trying to make an alarm every 15 mins as long as the system time is not greater than the designated set time and when the set time has reached, the alarm should go off. but my problem is, it keeps repeating every 15 minutes even after the past set time and it completely ignores the code in the else block.Am i doing the logic incorrectly?.. Any ideas will be greatly appreciated. Thank you.