JobScheduler: setperiodic + setRequiredNetworkType

when do i use setPeriodic

and setRequiredNetworkType

what if not at the end of the period RequiredNetworkType

? will the task work anyway or will it be postponed? I mean, I need the task to run every 30 minutes if it's a WIFI connection, otherwise after one hour any available connection can be used.

how to do it?

+3


source to share


1 answer


According to the docs for JobInfo.Builder.setRequiredNetworkType , if the required network type is not available, the job will never start. I don't think there is any callback to tell you this is not working.



So for your case, I would suggest having two jobs, one limited WiFi and one for any type of network. If the WiFi job runs, it records its status, perhaps by saving the time it was running in preference, and when the any-network job starts, it checks the preference the last time the WiFi job ran, and only continues if WiFi didn't work for the last hour.

0


source







All Articles