Android Worker PeriodicWorkRequest错误

时间:2019-08-20 21:33:23

标签: android worker

我尝试每12小时执行一次任务启动。我正在使用Android worker执行此任务。

在执行过程中发现了一个有趣的错误。

implementation "androidx.work:work-runtime:2.2.0"
Constraints constraints = new Constraints.Builder()
                .setRequiresCharging(true)
                .setRequiredNetworkType(NetworkType.CONNECTED)
                .build();
        PeriodicWorkRequest uploadWorkRequest = new PeriodicWorkRequest.Builder(UrlRequestsService.class,12, TimeUnit.HOURS)
                .setConstraints(constraints)
                .build();
        WorkManager.getInstance(context).enqueueUniquePeriodicWork("Send Data", ExistingPeriodicWorkPolicy.KEEP,uploadWorkRequest);

我的日志-任务工作是随机的。

2019-08-21 00:21:14.281 17993-18154/com.app I/UrlRequestsService: doWork
2019-08-21 00:25:12.790 17993-18291/com.app I/UrlRequestsService: doWork
2019-08-21 00:25:13.769 17993-18292/com.app I/UrlRequestsService: doWork

Android 9.设备-Galaxy S 10

0 个答案:

没有答案