Fixed
Status Update
Comments
su...@google.com <su...@google.com> #2
`Retry` is a signal that you want us to treat the Worker as ENQUEUED and backed off.
This is something you can do from inside a Worker using getRunAttemptCount() or keep track of this on your own.
This is something you can do from inside a Worker using getRunAttemptCount() or keep track of this on your own.
ch...@gmail.com <ch...@gmail.com> #3
While we can't expose "RETRY" because it's not a WorkInfo.State, what we can do is expose the runAttemptCount so you can figure out it's being retried.
[Deleted User] <[Deleted User]> #4
Great, being able to access 'runAttemptCount' from outside the Worker would allow me to handle the same thing very easily. I appreciate you entertaining my request.
su...@google.com <su...@google.com> #6
Reopening so I can just rename it to WorkResult.
ch...@instacart.com <ch...@instacart.com> #8
Thanks Sumir!
Description
Version used: 1.0.0-alpha12
After upgrading to alpha12, all of my Workers written in Kotlin (and CoroutineWorkers, FWIW), complain about the 'Result' return value with an error that says: "One type argument expected for class Result<out T>"
It appears that the Kotlin standard library contains a public inline Result class already:
The Kotlin Result class is automatically available in every file, so Android Studio (3.2.1) doesn't offer to import the androidx.work.Result class, causing the error since it assumes you want to use the already available kotlin Result.
There were two workarounds, neither very friendly:
1) Use the fully qualified androidx.work.Result
2) Manually adding the androidx.work.Result import statement
Note that:
- Using the fully qualified name, then using the Android Studio option to add import did not work
- Removing the doWork method entirely and using Android Studio's quick fix to implement the method did add an import to androidx.work.Result, so new classes would avoid running into this issue.