Periodic JobScheduler doesn't respect constraints

后端 未结 1 866
清酒与你
清酒与你 2021-01-20 12:26

Using the JobScheduler, I set up a simple JobService as follows:

@TargetApi(21)
public class SimpleJobService extends JobService {
    private static final S         


        
相关标签:
1条回答
  • 2021-01-20 13:10

    A periodic job has an implicit deadline of the end of the period as seen in the source code.

    Just like explicitly setting a deadline, this gives you an opportunity to decide on how best to handle extended periods of time (you'll note there is a minimum interval, queryable on Android 7.0+ devices with getMinPeriodMillis()) when your conditions are not met. For example, if your constraints are hard requirements, you can call jobFinished(jobParameters, false) to wait for the next periodic end point or the conditions to be true.

    0 讨论(0)
提交回复
热议问题