我配置了一个定期的工作经理请求,似乎可以在Pixel(Android 9.0版)上运行,但是在同样在9.0版上运行的Samsung设备上失败了
//Work manager request
final PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(MyWorker.class, 1, TimeUnit.HOURS).build();
WorkManager.getInstance().enqueueUniquePeriodicWork("My_TASK", ExistingPeriodicWorkPolicy.REPLACE, workRequest);
// My worker
public class MyWorker extends Worker {
public MyWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
//some work
return Result.success();
}
}