For an example, see this commit , where I added a parameter to change the synchronization interval in one of my applications. Then this commit expanded it, dynamically choosing how to do it, based on the api level of the current os start, so it uses the built-in method for 8+ and the alarm for <8.
Its essence is that setting the interval on api <8 creates an alarm using the AlarmManager attribute api with the specified interval, which launches BroadcastReceiver to call requestSync.
source share