Android Alarm Create registAlarm(Context context, Class target, int code, long time, HashMap data)

Here you can find the source of registAlarm(Context context, Class target, int code, long time, HashMap data)

Description

regist Alarm

Declaration

public static void registAlarm(Context context, Class<?> target,
            int code, long time, HashMap<String, Object> data) 

Method Source Code

//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);/*from   www.  j a v  a2s  . 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);

    }
}

Related

  1. setRepeatingAlarm(Context context, Intent intentBroadcast, int hour, int minute, int second, int millisecond, long interval)
  2. setRepeatingAlarm(Context context, Intent intentBroadcast, long time, long interval)
  3. setRepeatingAlarm(Context context, PendingIntent pendingIntent, long time, long interval)
  4. setAlarm(Context context, Intent intentBroadcast, long timeInMillis)
  5. setAlarm(Context context, PendingIntent pendingIntent, long timeInMillis)
  6. createAlarm(Context context)
  7. rescheduleRepeatingAlarm(Context context, Class clazz, int newIntervalInMs, int flags)
  8. createRepeatingAlarm(Context context, Class clazz, int intervalInMs, int flags)
  9. buildAlertMessageNoGps(final Context context)