添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

PeriodicWorkRequest not working correctly #69

Closed
@TechnoMag82

Description

android {
compileSdkVersion 28
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
private void startWorker() {
        Constraints constraints =
                new Constraints.Builder()
                        .setRequiredNetworkType(NetworkType.CONNECTED)
                        .build();
        PeriodicWorkRequest myWorkRequest =
                new PeriodicWorkRequest.Builder(UpdateWeatherWorker.class, 1, TimeUnit.MINUTES)
                        .setConstraints(constraints)
                        .build();
        WorkManager.getInstance().enqueueUniquePeriodicWork("12312ds", ExistingPeriodicWorkPolicy.KEEP, myWorkRequest);
public class UpdateWeatherWorker extends Worker {
    public static final String TAG = UpdateWeatherWorker.class.getSimpleName();
    @NonNull
    @Override
    public Result doWork() {
        if (BuildConfig




    
.DEBUG)
            Log.d(TAG, "worker started");
        return Worker.Result.RETRY;

Time of start Worker is not periodically in 1 minute:

08-07 11:23:15.905 11773-11814/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:23:15.917 11773-11814/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:23:46.052 11773-11854/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:23:46.062 11773-11854/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:24:46.323 11773-11872/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:24:46.328 11773-11872/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:26:46.560 11773-11814/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:26:46.566 11773-11814/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:30:46.794 11773-11854/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:30:46.799 11773-11854/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:39:42.133 11773-11872/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:39:42.139 11773-11872/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 11:55:42.240 11773-11814/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 11:55:42.255 11773-11814/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]
08-07 12:27:42.400 11773-11854/com.example.technomag.weatherapp D/UpdateWeatherWorker: worker started
08-07 12:27:42.413 11773-11854/com.example.technomag.weatherapp I/WorkerWrapper: Worker result RETRY for Work [ id=50a6a163-be82-40ba-a26f-cf47d8337c15, tags={ com.example.technomag.weatherapp.UpdateWeatherWorker } ]