Why workers in work manager still in ENQUEUED state?
Asked Answered
S

1

10

I'm creating OneTimeWorkRequest with NetworkType.CONNECTED constraint, but even though the device is connected to the internet, the request is still in ENQUEUED state

Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();

OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(SyncWorker.class)
            .setConstraints(constraints)
            .build();

WorkContinuation continuation = mWorkManager.beginUniqueWork("work",
                    ExistingWorkPolicy.KEEP, request);

continuation.enqueue();
Slashing answered 3/7, 2018 at 6:48 Comment(3)
have you found any solutions?Maricruzmaridel
Is your SyncWorker an inner class? https://mcmap.net/q/395023/-android-work-manager-quot-could-not-instantiate-worker-quotTamaratamarack
Did you find any solution? Some of my users are currently facing the same issues with some of their china phones like TecnoEmilemile
C
0

Try this?

Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();

OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(SyncWorker.class)
            .setConstraints(constraints)
            .build();

WorkManager.getInstance().enqueue(request);
Circumnavigate answered 3/7, 2018 at 7:37 Comment(2)
Have you debugged into your worker class to see if it is being executed? Is it possible it's not succeeding and therefore retrying itself?Circumnavigate
facing the same issue with the beta03 release of the library. Worker used to be triggered but since yesterday its not triggered at all and stays in enqueued state. I've set the same network constraint as above and time of 15 minutes. But its a periodic request in my case.Planchet

© 2022 - 2024 — McMap. All rights reserved.