Java tutorial
//package com.java2s; //License from project: Apache License import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; public class Main { public static void startAlert(AlarmManager alarmMgr, PendingIntent alarmIntent, Context context) { // alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); // Intent intent = new Intent(context, AlerReceiver.class); // alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); // Set the alarm to start at 8:30 a.m. // Calendar calendar = Calendar.getInstance(); // calendar.setTimeInMillis(System.currentTimeMillis()); // calendar.set(Calendar.HOUR_OF_DAY, 8); // calendar.set(Calendar.MINUTE, 30); // setRepeating() lets you specify a precise custom interval--in this case, // 20 minutes. // alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), // 1000 * 60 * 20, alarmIntent); alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 3000, alarmIntent); } }