1

重启设备后我的 FirebaseJobDispatcher 无法启动。我需要调度程序在设备重新启动后自动启动。

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

    Job myJob = dispatcher.newJobBuilder()
            .setService(ServiceAppControl.class)
            .setTag(AppGlobal.LOG_TAG)
            .setRecurring(false)
            .setLifetime(Lifetime.FOREVER)
            .setTrigger(Trigger.executionWindow(0, 5))
            .setReplaceCurrent(false)
            .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
            .setConstraints(
                    // only run on an unmetered network
                    Constraint.ON_UNMETERED_NETWORK,
                    // only run when the device is charging
                    Constraint.DEVICE_CHARGING
            )
            .build();
    dispatcher.mustSchedule(myJob);
4

1 回答 1

0

您是否将此权限添加到清单中?

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
于 2017-10-17T07:25:55.750 回答