Here you can find the source of setAlarm(Context context, Calendar alarmDate, PendingIntent pIntent)
@SuppressLint("NewApi") private static void setAlarm(Context context, Calendar alarmDate, PendingIntent pIntent)
//package com.java2s; import java.util.Calendar; import android.annotation.SuppressLint; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; public class Main { @SuppressLint("NewApi") private static void setAlarm(Context context, Calendar alarmDate, PendingIntent pIntent) {/* w w w . j av a2 s . com*/ 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, alarmDate.getTimeInMillis(), pIntent); } else { alarmManager.set(AlarmManager.RTC_WAKEUP, alarmDate.getTimeInMillis(), pIntent); } } }