setup Alarm by milliseconds - Android Android OS

Android examples for Android OS:Alarm Set Up

Description

setup Alarm by milliseconds

Demo Code


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

public class Main {

    public static void setupAlarm(Context context, int alarmId,
            Intent intent, long triggerAtMills) {
        AlarmManager alarmManager = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
        PendingIntent pi = PendingIntent.getBroadcast(context, alarmId,
                intent, PendingIntent.FLAG_UPDATE_CURRENT);
        alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMills, pi);
    }/*  w  w w.j  a  v a  2 s.com*/
}

Related Tutorials