Here you can find the source of setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
@SuppressLint("NewApi") private static void setAlarm(Context context, Calendar calendar, PendingIntent pIntent)
//package com.java2s; import android.annotation.SuppressLint; import android.app.AlarmManager; import android.content.Context; import android.app.PendingIntent; import java.util.Calendar; public class Main { @SuppressLint("NewApi") private static void setAlarm(Context context, Calendar calendar, PendingIntent pIntent) {/*ww w . ja v a2s. c o m*/ 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); } } }