Here you can find the source of setAlarm(Context context, PendingIntent pIntent)
private static void setAlarm(Context context, PendingIntent pIntent)
//package com.java2s; //License from project: Apache License import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; public class Main { private static void setAlarm(Context context, PendingIntent pIntent) { AlarmManager alarmManager = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 5000, 5000, pIntent); } else {/*ww w .j a va 2s .com*/ alarmManager.set(AlarmManager.ELAPSED_REALTIME, 5000, pIntent); } } }