我的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);
答案 0 :(得分:0)
您是否已将此权限添加到清单中?
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>