schedule a Repeat Alarm by starting milliseconds and interval milliseconds - Android Android OS

Android examples for Android OS:Alarm Start

Description

schedule a Repeat Alarm by starting milliseconds and interval milliseconds

Demo 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 void scheduleRepeat(Context context, Intent intent,
            long triggerAtMillis, long intervalMillis) {
        PendingIntent p = PendingIntent.getBroadcast(context, 1, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarme = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
        alarme.setInexactRepeating(AlarmManager.RTC_WAKEUP,
                triggerAtMillis, intervalMillis, p);
    }//from  ww w. j  a va  2 s  . c o m
}

Related Tutorials