Search code examples
androidadmobandroid-workmanager

Is it possible to use workmanger instead of ScheduledExecutorService for showing interstitial ad in evey n minutes?


I want show my interstitial ad in every 10 minutes and most tutorials suggests using ScheduledExecutorService but I wonder if I can use workmanager instead?


Solution

  • No. WorkManager is specifically meant for deferrable, persistent work and not for work 1) tied to your UI or 2) on a specific timing schedule. From the WorkManager Overview:

    The WorkManager API makes it easy to schedule deferrable, asynchronous tasks that are expected to run even if the app exits or device restarts.

    WorkManager is not intended for in-process background work that can safely be terminated if the app process goes away or for tasks that require immediate execution. Please review the background processing guide to see which solution meets your needs.