FirebaseJobDispatcher无法在Oreo 8.1上定期运行

时间:2018-08-23 17:57:04

标签: android android-8.1-oreo firebase-job-dispatcher

在Nokia1 TA-1066型号Android v 8.1.0上,调度程序未定期运行。我尝试在“启动”中添加测试计划程序,但未运行。这是代码段,感谢您的快速帮助。

<service
    android:name=".TestFBDispJobService"
    android:enabled="true">
    <intent-filter>
        <action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE"/>
    </intent-filter>
</service>



    FirebaseJobDispatcher test1 = new FirebaseJobDispatcher(new GooglePlayDriver(context));
    Job job = test1.newJobBuilder()
            //persist the task across boots
            .setLifetime(Lifetime.FOREVER)
            //call this service when the criteria are met.
            .setService(TestFBDispJobService.class)
            //unique id of the task
            .setTag("TEST1")
            //don't overwrite an existing job with the same tag
            .setReplaceCurrent(true)
            // We are mentioning that the job is periodic.
            .setRecurring(true)
            .setTrigger(Trigger.executionWindow( (60 * 15),
                    ((60 * 20) + (60 * 5)))
            // retry with exponential backoff
            .setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
            //.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
            //Run this job only when the network is available.
            .setConstraints(Constraint.ON_ANY_NETWORK)
            .build();
    test1.mustSchedule(job);

0 个答案:

没有答案