Android Alarm Create createAlarm(Context context)

Here you can find the source of createAlarm(Context context)

Description

create Alarm

Declaration

public static void createAlarm(Context context) 

Method Source Code

//package com.java2s;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import android.util.Log;

public class Main {
    public static final String TEST_RECEIVER = "TestReceiver";
    private static final int REQUEST_CODE = 1000;

    public static void createAlarm(Context context) {
        Intent intent = new Intent("test_action");
        PendingIntent sender = PendingIntent.getBroadcast(context,
                REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        Log.v(TEST_RECEIVER, "sender:" + sender);

        AlarmManager am = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
        //      am.cancel(sender);
        am.setRepeating(AlarmManager.RTC_WAKEUP,
                System.currentTimeMillis() + 100 * 1000, 30 * 1000, sender);
    }// www  . j  a va  2 s  . co  m
}

Related

  1. setRepeatingAlarm(Context context, Intent intentBroadcast, long time, long interval)
  2. setRepeatingAlarm(Context context, PendingIntent pendingIntent, long time, long interval)
  3. setAlarm(Context context, Intent intentBroadcast, long timeInMillis)
  4. setAlarm(Context context, PendingIntent pendingIntent, long timeInMillis)
  5. registAlarm(Context context, Class target, int code, long time, HashMap data)
  6. rescheduleRepeatingAlarm(Context context, Class clazz, int newIntervalInMs, int flags)
  7. createRepeatingAlarm(Context context, Class clazz, int intervalInMs, int flags)
  8. buildAlertMessageNoGps(final Context context)