Android Utililty Methods Alarm Create

List of utility methods to do Alarm Create

Description

The list of methods to do Alarm Create are organized into topic(s).

Method

voidsetAlarm(Context context, Calendar calendar, PendingIntent pIntent)
Create an alarm in the alarm manager using the given time in CALENDAR with the given PINTENT
AlarmManager alarmManager = (AlarmManager) context
        .getSystemService(Context.ALARM_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
    alarmManager.setExact(AlarmManager.RTC_WAKEUP,
            calendar.getTimeInMillis(), pIntent);
} else {
    alarmManager.set(AlarmManager.RTC_WAKEUP,
            calendar.getTimeInMillis(), pIntent);
...
voidsetBoolean(ContentValues alarm, String key, boolean value)
set Boolean
alarm.put(key, (Integer) (value ? 1 : 0));
voidsetRepeatingAlarm(Context context, Intent intentBroadcast, int hour, int minute, int second, int millisecond, long interval)
set Repeating Alarm
AlarmManager alarm = (AlarmManager) context
        .getSystemService(Context.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, second);
calendar.set(Calendar.MILLISECOND, millisecond);
intentBroadcast.setAction(SET_ALARM);
...
voidsetRepeatingAlarm(Context context, Intent intentBroadcast, long time, long interval)
set Repeating Alarm
AlarmManager am = (AlarmManager) context
        .getSystemService(Context.ALARM_SERVICE);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
        0, intentBroadcast, PendingIntent.FLAG_UPDATE_CURRENT);
am.setRepeating(AlarmManager.RTC_WAKEUP, time, interval,
        pendingIntent);
voidsetRepeatingAlarm(Context context, PendingIntent pendingIntent, long time, long interval)
set Repeating Alarm
AlarmManager am = (AlarmManager) context
        .getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, time, interval,
        pendingIntent);
voidsetAlarm(Context context, Intent intentBroadcast, long timeInMillis)
set Alarm
AlarmManager am = (AlarmManager) context
        .getSystemService(Context.ALARM_SERVICE);
PendingIntent sender = PendingIntent.getBroadcast(context, 0,
        intentBroadcast, PendingIntent.FLAG_UPDATE_CURRENT);
am.set(AlarmManager.RTC_WAKEUP, timeInMillis, sender);
voidsetAlarm(Context context, PendingIntent pendingIntent, long timeInMillis)
set Alarm
AlarmManager am = (AlarmManager) context
        .getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, timeInMillis, pendingIntent);
voidregistAlarm(Context context, Class target, int code, long time, HashMap data)
regist Alarm
Intent intent = new Intent(context, target);
for (String key : data.keySet()) {
    intent.removeExtra(key);
    intent.putExtra(key, String.valueOf(data.get(key)));
PendingIntent sender = PendingIntent.getBroadcast(context, code,
        intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager manager = (AlarmManager) context
...
voidcreateAlarm(Context context)
create Alarm
Intent intent = new Intent("test_action");
PendingIntent sender = PendingIntent.getBroadcast(context,
        REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Log.v(TEST_RECEIVER, "sender:" + sender);
AlarmManager am = (AlarmManager) context
        .getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP,
        System.currentTimeMillis() + 100 * 1000, 30 * 1000, sender);
...
voidrescheduleRepeatingAlarm(Context context, Class clazz, int newIntervalInMs, int flags)
reschedule Repeating Alarm
cancelAlarm(context, clazz, flags);
createRepeatingAlarm(context, clazz, newIntervalInMs, flags);