Android Alarm Create setAlarm(Context context, Calendar calendar, PendingIntent pIntent)

Here you can find the source of setAlarm(Context context, Calendar calendar, PendingIntent pIntent)

Description

Create an alarm in the alarm manager using the given time in CALENDAR with the given PINTENT

Declaration

@SuppressWarnings("NewApi")
private static void setAlarm(Context context, Calendar calendar,
        PendingIntent pIntent) 

Method Source Code

//package com.java2s;
import android.app.AlarmManager;
import android.app.PendingIntent;

import android.content.Context;

import java.util.Calendar;

public class Main {
    /**/*w w  w.j ava2  s  . c o m*/
     * Create an alarm in the alarm manager using the given time in CALENDAR with the given
     * PINTENT
     */
    @SuppressWarnings("NewApi")
    private static void setAlarm(Context context, Calendar calendar,
            PendingIntent 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);
        }
    }
}

Related

  1. setPendingAndroidAlarm(Context context, Calendar calendar, PendingIntent pIntent)
  2. setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
  3. setupAlarmManager(Context context, long minutesInMillis, PendingIntent pendingIntent)
  4. setExact(AlarmManager alarmManger, int type, long triggerAtMillis, PendingIntent operation)
  5. setExact(AlarmManager alarmManger, int type, long triggerAtMillis, PendingIntent operation)
  6. setBoolean(ContentValues alarm, String key, boolean value)
  7. setRepeatingAlarm(Context context, Intent intentBroadcast, int hour, int minute, int second, int millisecond, long interval)
  8. setRepeatingAlarm(Context context, Intent intentBroadcast, long time, long interval)
  9. setRepeatingAlarm(Context context, PendingIntent pendingIntent, long time, long interval)