Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Subtract minutes to my alarm
    primarykey
    data
    text
    <p>I'm making an alarm, get the current time as follows:</p> <pre><code>public String getAlarmTimeStringFive2db() { String timef2db = ""; if (alarmTime.get(Calendar.HOUR_OF_DAY) &lt;= 9) timef2db += "0"; timef2db += String.valueOf(alarmTime.get(Calendar.HOUR_OF_DAY)); timef2db += ":"; if (alarmTime.get(Calendar.MINUTE) &lt;= 9) timef2db += "0"; timef2db += String.valueOf(alarmTime.get(Calendar.MINUTE)); return timef2db; } ... public static long create(Alarm alarm) { ContentValues cv = new ContentValues(); cv.put(COLUMN_ALARM_ACTIVE, alarm.getAlarmActive()); cv.put(COLUMN_ALARM_TIME, alarm.getAlarmTimeStringFive2db()); ... public void setAlarmTime(String alarmTime) { String[] timePieces = alarmTime.split(":"); Calendar newAlarmTime = Calendar.getInstance(); newAlarmTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timePieces[0])); newAlarmTime.set(Calendar.MINUTE, Integer.parseInt(timePieces[1])); newAlarmTime.set(Calendar.SECOND, 0); setAlarmTime(newAlarmTime); } </code></pre> <p>...</p> <p>This works fine, for example returns 5:35 ... all right.</p> <p>My problem is I want to subtract 5 minutes always on time. If the time is 5:35, I want the alarm time starts at 5:30.</p> <p>My problem is I do not know how to subtract those 5 minutes. I tried</p> <p>Calendar.MINUTE, Integer.parseInt(timePieces[1],5)</p> <p>Calendar.MINUTE, -5)</p> <p>...but nothing works</p> <p>I read this link <a href="https://stackoverflow.com/questions/11857251/set-alarm-to-alert-5-minutes-before-a-certian-time">Set Alarm To Alert 5 Minutes Before a certian Time</a> .. but I could not apply it to my code</p> <p>Can anyone tell me as subtracting 5 minutes of my alarm?</p> <p>thanks in advance</p> <p>Regards</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload