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

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

Description

helper method that schedules a pending alarm intent over android's AlarmManager

Declaration

@SuppressLint("NewApi")
private static void setPendingAndroidAlarm(Context context,
        Calendar calendar, PendingIntent pIntent) 

Method Source Code

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

import android.content.Context;

import java.util.Calendar;

public class Main {
    /**//  ww w. j  a v a 2  s  . c  o  m
     * helper method that schedules a pending alarm intent over android's {@link AlarmManager}
     */
    @SuppressLint("NewApi")
    private static void setPendingAndroidAlarm(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. setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
  2. setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
  3. setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
  4. setAlarm(Context context, Calendar alarmDate, PendingIntent pIntent)
  5. setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
  6. setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
  7. setupAlarmManager(Context context, long minutesInMillis, PendingIntent pendingIntent)
  8. setExact(AlarmManager alarmManger, int type, long triggerAtMillis, PendingIntent operation)
  9. setExact(AlarmManager alarmManger, int type, long triggerAtMillis, PendingIntent operation)