set Inexact Repeating Alarm - Android android.app

Android examples for android.app:Alarm Set up

Description

set Inexact Repeating Alarm

Demo Code

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class Main{

    public static void setInexactRepeating(Context context, int alarmId,
            Intent intent, long triggerAtMills, long intervalMills) {
        AlarmManager alarmManager = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
        PendingIntent pi = PendingIntent.getBroadcast(context, alarmId,
                intent, PendingIntent.FLAG_UPDATE_CURRENT);
        alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
                triggerAtMills, intervalMills, pi);
    }//from w  w w . j ava 2  s. c  o  m

}

Related Tutorials