WorkerParameters
class WorkerParameters
Setup parameters for a ListenableWorker.
Summary
Public functions |
|
|---|---|
@IntRange(from = 0) Int |
Gets the generation of this Worker. |
UUID |
getId()Gets the ID of the |
Data |
Gets the input data. |
Network? |
@RequiresApi(value = 28)Gets the |
@IntRange(from = 0) Int |
Gets the current run attempt count for this work. |
(Mutable)Set<String!> |
getTags()Gets a |
(Mutable)List<String!> |
@RequiresApi(value = 24)Gets the list of content authorities that caused this Worker to execute. |
(Mutable)List<Uri!> |
@RequiresApi(value = 24)Gets the list of content |
Extension functions |
|
|---|---|
Boolean |
|
inline WorkerParameters |
<T : ListenableWorker> WorkerParameters.usingRemoteService(Returns a new instance of |
WorkerParameters |
WorkerParameters.usingRemoteService(Returns a new instance of |
Public functions
getGeneration
fun getGeneration(): @IntRange(from = 0) Int
Gets the generation of this Worker.
A work has multiple generations, if it was updated via updateWork or enqueueUniquePeriodicWork using UPDATE. This worker can possibly be of an older generation rather than latest known, if an update has happened while this worker is running.
getId
fun getId(): UUID
Gets the ID of the WorkRequest that created this ListenableWorker.
| Returns | |
|---|---|
UUID |
The ID of the creating |
getInputData
fun getInputData(): Data
Gets the input data. Note that in the case that there are multiple prerequisites for this ListenableWorker, the input data has been run through an InputMerger.
| Returns | |
|---|---|
Data |
The input data for this work |
| See also | |
|---|---|
setInputMerger |
getNetwork
@RequiresApi(value = 28)
fun getNetwork(): Network?
Gets the android.net.Network to use for this Worker. This method returns null if there is no network needed for this work request.
| Returns | |
|---|---|
Network? |
The |
getRunAttemptCount
fun getRunAttemptCount(): @IntRange(from = 0) Int
Gets the current run attempt count for this work. Note that for periodic work, this value gets reset between periods.
getTags
fun getTags(): (Mutable)Set<String!>
Gets a java.util.Set of tags associated with this Worker's WorkRequest.
| Returns | |
|---|---|
(Mutable)Set<String!> |
The |
| See also | |
|---|---|
addTag |
getTriggeredContentAuthorities
@RequiresApi(value = 24)
fun getTriggeredContentAuthorities(): (Mutable)List<String!>
Gets the list of content authorities that caused this Worker to execute. See JobParameters#getTriggeredContentAuthorities() for relevant JobScheduler code.
getTriggeredContentUris
@RequiresApi(value = 24)
fun getTriggeredContentUris(): (Mutable)List<Uri!>
Gets the list of content android.net.Uris that caused this Worker to execute. See
JobParameters#getTriggeredContentUris()} for relevant JobScheduler code.
| Returns | |
|---|---|
(Mutable)List<Uri!> |
The list of content |
| See also | |
|---|---|
addContentUriTrigger |
Extension functions
isRemoteWorkRequest
fun WorkerParameters.isRemoteWorkRequest(): Boolean
| Returns | |
|---|---|
Boolean |
|
usingRemoteService
inline fun <T : ListenableWorker> WorkerParameters.usingRemoteService(
componentName: ComponentName
): WorkerParameters
Returns a new instance of WorkerParameters representing a WorkRequest that can run in a process corresponding to the provided ComponentName.
| Parameters | |
|---|---|
<T : ListenableWorker> |
The |
componentName: ComponentName |
The |
| Returns | |
|---|---|
WorkerParameters |
A new instance of |
usingRemoteService
fun WorkerParameters.usingRemoteService(
workerClassName: String,
componentName: ComponentName
): WorkerParameters
Returns a new instance of WorkerParameters representing a WorkRequest that can run in a process corresponding to the provided ComponentName.
| Parameters | |
|---|---|
workerClassName: String |
The fully qualified class name of the |
componentName: ComponentName |
The |
| Returns | |
|---|---|
WorkerParameters |
A new instance of |