我有一项需要执行互联网的任务,必须每天无限期执行,下面是我为执行相同操作而编写的代码
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job myJob = dispatcher.newJobBuilder()
.setService(FirebaseJobDispatcherService.class) // the JobService that will be called
.setTag(Constants.ALERT_TAG) // uniquely identifies the job
.setRecurring(true)
.setLifetime(Lifetime.FOREVER)
.setReplaceCurrent(true)
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.setTrigger(Trigger.executionWindow(0, (int) TimeUnit.DAYS.toSeconds(1)))
.setConstraints(Constraint.ON_ANY_NETWORK)
.build();
dispatcher.mustSchedule(myJob);
现在的问题是,它可以在像Moto,三星等普通设备上正常工作,但在像OnePlus这样的自定义ROM上,小米只有在应用程序打开时才会触发作业。有没有人遇到过这个问题,或者知道如何让它在Custom ROM上正常工作?