schedule an Alarm by milliseconds - Android Android OS

Android examples for Android OS:Alarm Information

Description

schedule an Alarm by 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 schedule(Context context, Intent intent,
            long triggerAtMillis) {
        PendingIntent p = PendingIntent.getBroadcast(context, 1, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarme = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
        alarme.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, p);
    }/*  w  w w .  j av a 2 s.c om*/
}

Related Tutorials