Search code examples
androiddebuggingandroid-workmanager

How can I reduce the minimum interval for periodic work requests?


I know that there is a minimum interval of 15 minutes when requesting periodic work from a WorkManager and I understand the reason for that.

Yet, for debugging purposes when I want to test how some work is scheduled and run, it is extremely annoying to have to wait for 15 minutes to see the results. For some debugging tasks, when especially the behavior of WorkManager needs to be checked, it seems to be no option to use a workaround like an alarm service.

So is there a possibility to get around the minimum periodic interval only temporarily for debugging?


Solution

  • So is there a possibility to get around the minimum periodic interval only temporarily for debugging?

    No, because then developers would use it for any reason.

    it is extremely annoying to have to wait for 15 minutes to see the results

    Write unit tests of your Worker.

    Or, write instrumented tests of your Worker.

    Or, make your Worker be a very thin wrapper around some other code that contains the actual business logic. Use the Worker for the periodic aspect, and use the wrapped code directly for debugging (e.g., temporarily hook it up to a Button).