Android examples for Android OS:Alarm Set Up
register Alarm
//package com.java2s; import java.util.HashMap; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; public class Main { public static void registAlarm(Context context, Class<?> target, int code, long time, HashMap<String, Object> data) { Intent intent = new Intent(context, target); for (String key : data.keySet()) { intent.removeExtra(key);/* ww w.j a v a 2 s .c o m*/ intent.putExtra(key, String.valueOf(data.get(key))); } PendingIntent sender = PendingIntent.getBroadcast(context, code, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager manager = (AlarmManager) context .getSystemService(Context.ALARM_SERVICE); manager.set(AlarmManager.RTC_WAKEUP, time, sender); } }