Since Android 5.1 (API Level 22), AlarmManager's setRepeating method forcefully raise intervals under 1 minute (60000 msec) to 1 minute. Although it is completely right decision because waking up phone every 15 seconds or 30 seconds is crazy, but SOMETIMES (for testing, researching, ...) we need such kind of 'bad' alarms. However, we can overcome this shortcoming by setting once-only alarm repetitively(not explicitly calling setRepeating but call set or setExact again and again, like a chain).


For example, previously we have alarms like this:

mAlarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent alarmIntent = new Intent(this, PeriodicWorker.class); alarmIntent.setAction(ACTION_WAKEUP); PendingIntent pendingAlarmIntent = PendingIntent.getService(this, 0, alarmIntent, 0); mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), ALARM_INTERVAL, pendingAlarmIntent);

However, from the API Level 22 (Android 5.1), we have to do it manually like this:

if (mAlarmManager == null) mAlarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
Intent alarmIntent = new Intent(this, PeriodicWorker.class);
alarmIntent.setAction(ACTION_WAKEUP);
PendingIntent pendingAlarmIntent = PendingIntent.getService(this, 0, alarmIntent, 0);
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + ALARM_INTERVAL, pendingAlarmIntent);