Code example for AlarmManager

Methods: set

0
                intentFilter, null, new Handler(looper));
    } 
 
    private void scheduleUpdateIdleMaintenanceState(long delayMillis) {
        final long triggetRealTimeMillis = SystemClock.elapsedRealtime() + delayMillis;
        mAlarmService.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggetRealTimeMillis,
                mUpdateIdleMaintenanceStatePendingIntent);
    } 
 
    private void unscheduleUpdateIdleMaintenanceState() { 
        mAlarmService.cancel(mUpdateIdleMaintenanceStatePendingIntent);
    } 
 
    private void updateIdleMaintenanceState() { 
        if (mIdleMaintenanceStarted) {
            // Idle maintenance can be interrupted by user activity, or duration 
            // time out, or low battery. 
            if (!lastUserActivityPermitsIdleMaintenanceRunning() 
                    || !batteryLevelAndMaintenanceTimeoutPermitsIdleMaintenanceRunning()) { 
                unscheduleUpdateIdleMaintenanceState();