Code example for AlarmManager

Methods: set

0
            // postpone notification service launch a minute, 
            // we don't want to slow down booting 
            AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
            Intent i = new Intent(context, OnAlarmReceiver.class);
            PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
            am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1
                    * DateUtils.MINUTE_IN_MILLIS, pi);
            Log.d("OnAlarmReceiver", "Postponing service launch");
        } else { 
            // run the notification service right away 
            Log.d("OnAlarmReceiver", "Run notifications service right away");
            Utils.runNotificationService(context);
        } 
    } 
}