1

Is it ok to run service every 1 minute forever using Firebase JobDispatcher. what is the recommend interval for Recurring task?

FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));


            Job myJob = dispatcher.newJobBuilder()
                    // the JobService that will be called
                    .setService(NotificationService.class)
                    // uniquely identifies the job
                    .setTag("MU_TAG")
                    // one-off job
                    .setRecurring(true)
                    // don't persist past a device reboot
                    .setLifetime(Lifetime.FOREVER)
                    // start between 0 and 60 seconds from now
                    .setTrigger(Trigger.executionWindow(60, 60 + 1))
                    // don't overwrite an existing job with the same tag
                    .setReplaceCurrent(true)
                    // retry with exponential backoff
                    .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
                    .build();

            dispatcher.mustSchedule(myJob);
gsk_sarath
  • 15
  • 6

1 Answers1

0

I don't know what you are trying to implement. However, as you may think, repeating forever every 1minute is not a good idea.

You may try to run it after a specific event so that the program avoids using its resources wastefully.

c-an
  • 3,543
  • 5
  • 35
  • 82