Here you can find the source of setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
@SuppressWarnings("NewApi") private static void setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
//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); } } }