get Next Alarm Time - Android Android OS

Android examples for Android OS:Alarm Information

Description

get Next Alarm Time

Demo Code


//package com.java2s;

import android.content.Context;

import android.text.format.Time;

public class Main {
    public static Time getNextAlarmTime(Context context, Time time,
            int randomMinute) {
        Time now = new Time();
        Time alarmTime = new Time();
        now.setToNow();/*from   w ww  . ja  va  2  s  . c  om*/
        alarmTime.set(now);
        alarmTime.set(now.second, time.minute, time.hour, now.monthDay,
                now.month, now.year);
        alarmTime.normalize(false);
        alarmTime.minute += randomMinute;
        alarmTime.normalize(false);
        if (alarmTime.before(now)) {
            alarmTime.monthDay += 1;
            alarmTime.normalize(false);
        }

        return alarmTime;
    }
}

Related Tutorials