# WorkerParameters

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/WorkerParameters.java+class:androidx.work.WorkerParameters) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

*** ** * ** ***


```
public final class WorkerParameters
```

<br />

*** ** * ** ***

Setup parameters for a `https://developer.android.com/reference/androidx/work/ListenableWorker`.

## Summary

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/work/WorkerParameters#getGeneration()()` Gets the generation of this Worker. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/UUID.html` | `https://developer.android.com/reference/androidx/work/WorkerParameters#getId()()` Gets the ID of the `https://developer.android.com/reference/androidx/work/WorkRequest` that created this `https://developer.android.com/reference/androidx/work/ListenableWorker`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/work/Data` | `https://developer.android.com/reference/androidx/work/WorkerParameters#getInputData()()` Gets the input data. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Network.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 28) https://developer.android.com/reference/androidx/work/WorkerParameters#getNetwork()()` Gets the `https://developer.android.com/reference/android/net/Network.html` to use for this Worker. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | `https://developer.android.com/reference/androidx/work/WorkerParameters#getRunAttemptCount()()` Gets the current run attempt count for this work. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/work/WorkerParameters#getTags()()` Gets a `https://developer.android.com/reference/java/util/Set.html` of tags associated with this Worker's `https://developer.android.com/reference/androidx/work/WorkRequest`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 24) https://developer.android.com/reference/androidx/work/WorkerParameters#getTriggeredContentAuthorities()()` Gets the list of content authorities that caused this Worker to execute. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/android/net/Uri.html>` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 24) https://developer.android.com/reference/androidx/work/WorkerParameters#getTriggeredContentUris()()` Gets the list of content `https://developer.android.com/reference/android/net/Uri.html`s that caused this Worker to execute. |

| ### Extension functions |
|---|---|
| `final boolean` | `https://developer.android.com/reference/androidx/work/WorkerParametersExtensions.https://developer.android.com/reference/androidx/work/WorkerParameters#(androidx.work.WorkerParameters).isRemoteWorkRequest()( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerParameters receiver )` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerParameters` | `<T extends https://developer.android.com/reference/androidx/work/ListenableWorker> https://developer.android.com/reference/androidx/work/WorkerParametersExtensions.https://developer.android.com/reference/androidx/work/WorkerParameters#(androidx.work.WorkerParameters).usingRemoteService(android.content.ComponentName)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerParameters receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName )` Returns a new instance of `https://developer.android.com/reference/androidx/work/WorkerParameters` representing a `https://developer.android.com/reference/androidx/work/WorkRequest` that can run in a process corresponding to the provided `https://developer.android.com/reference/android/content/ComponentName.html`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerParameters` | `https://developer.android.com/reference/androidx/work/WorkerParametersExtensions.https://developer.android.com/reference/androidx/work/WorkerParameters#(androidx.work.WorkerParameters).usingRemoteService(kotlin.String,android.content.ComponentName)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerParameters receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html workerClassName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName )` Returns a new instance of `https://developer.android.com/reference/androidx/work/WorkerParameters` representing a `https://developer.android.com/reference/androidx/work/WorkRequest` that can run in a process corresponding to the provided `https://developer.android.com/reference/android/content/ComponentName.html`. |

## Public methods

### getGeneration

Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/work#2.8.0)

```
public @IntRange(from = 0) int getGeneration()
```

Gets the generation of this Worker.

A work has multiple generations, if it was updated via `https://developer.android.com/reference/androidx/work/WorkManager#updateWork(androidx.work.WorkRequest)` or `https://developer.android.com/reference/androidx/work/WorkManager#enqueueUniquePeriodicWork(java.lang.String,androidx.work.ExistingPeriodicWorkPolicy,androidx.work.PeriodicWorkRequest)` using `https://developer.android.com/reference/androidx/work/ExistingPeriodicWorkPolicy#UPDATE`. This worker can possibly be of an older generation rather than latest known, if an update has happened while this worker is running.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | a generation of this work. |

### getId

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public @NonNull UUID getId()
```

Gets the ID of the `https://developer.android.com/reference/androidx/work/WorkRequest` that created this `https://developer.android.com/reference/androidx/work/ListenableWorker`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/UUID.html` | The ID of the creating `https://developer.android.com/reference/androidx/work/WorkRequest` |

### getInputData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public @NonNull Data getInputData()
```

Gets the input data. Note that in the case that there are multiple prerequisites for this `https://developer.android.com/reference/androidx/work/ListenableWorker`, the input data has been run through an `https://developer.android.com/reference/androidx/work/InputMerger`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/work/Data` | The input data for this work |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/work/OneTimeWorkRequest.Builder#setInputMerger(java.lang.Class<? extends androidx.work.InputMerger>)` |   |

### getNetwork

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
@RequiresApi(value = 28)
public @Nullable Network getNetwork()
```

Gets the `https://developer.android.com/reference/android/net/Network.html` to use for this Worker. This method returns `null` if there is no network needed for this work request.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/net/Network.html` | The `https://developer.android.com/reference/android/net/Network.html` specified by the OS to be used with this Worker |

### getRunAttemptCount

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public @IntRange(from = 0) int getRunAttemptCount()
```

Gets the current run attempt count for this work. Note that for periodic work, this value gets reset between periods.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int` | The current run attempt count for this work. |

### getTags

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
public @NonNull Set<String> getTags()
```

Gets a `https://developer.android.com/reference/java/util/Set.html` of tags associated with this Worker's `https://developer.android.com/reference/androidx/work/WorkRequest`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html>` | The `https://developer.android.com/reference/java/util/Set.html` of tags associated with this Worker's `https://developer.android.com/reference/androidx/work/WorkRequest` |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/work/WorkRequest.Builder#addTag(java.lang.String)` |   |

### getTriggeredContentAuthorities

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
@RequiresApi(value = 24)
public @NonNull List<String> getTriggeredContentAuthorities()
```

Gets the list of content authorities that caused this Worker to execute. See `JobParameters#getTriggeredContentAuthorities()` for relevant `JobScheduler` code.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | The list of content authorities that caused this Worker to execute |

### getTriggeredContentUris

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

```
@RequiresApi(value = 24)
public @NonNull List<Uri> getTriggeredContentUris()
```

Gets the list of content `https://developer.android.com/reference/android/net/Uri.html`s that caused this Worker to execute. See

JobParameters#getTriggeredContentUris()} for relevant `JobScheduler` code.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/android/net/Uri.html>` | The list of content `https://developer.android.com/reference/android/net/Uri.html`s that caused this Worker to execute |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/work/Constraints.Builder#addContentUriTrigger(android.net.Uri,boolean)` |   |

## Extension functions

### WorkerParametersExtensions.isRemoteWorkRequest

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/WorkerParameters.kt+function:isRemoteWorkRequest)

```
public final boolean WorkerParametersExtensions.isRemoteWorkRequest(
    @NonNull WorkerParameters receiver
)
```

| Returns |
|---|---|
| `boolean` | `true` if and only if the instance of `https://developer.android.com/reference/androidx/work/WorkerParameters` corresponds to a `https://developer.android.com/reference/androidx/work/WorkRequest` that runs in a remote process. |

### WorkerParametersExtensions.usingRemoteService

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/WorkerParameters.kt+function:usingRemoteService)

```
public final @NonNull WorkerParameters <T extends ListenableWorker> WorkerParametersExtensions.usingRemoteService(
    @NonNull WorkerParameters receiver,
    @NonNull ComponentName componentName
)
```

Returns a new instance of `https://developer.android.com/reference/androidx/work/WorkerParameters` representing a `https://developer.android.com/reference/androidx/work/WorkRequest` that can run in a process corresponding to the provided `https://developer.android.com/reference/android/content/ComponentName.html`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/work/ListenableWorker>` | The `https://developer.android.com/reference/androidx/work/ListenableWorker` to delegate to. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName` | The `https://developer.android.com/reference/android/content/ComponentName.html` that identifies the `RemoteService` that hosts the `https://developer.android.com/reference/androidx/work/WorkRequest`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerParameters` | A new instance of `https://developer.android.com/reference/androidx/work/WorkerParameters` |

### WorkerParametersExtensions.usingRemoteService

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/WorkerParameters.kt+function:usingRemoteService)

```
public final @NonNull WorkerParameters WorkerParametersExtensions.usingRemoteService(
    @NonNull WorkerParameters receiver,
    @NonNull String workerClassName,
    @NonNull ComponentName componentName
)
```

Returns a new instance of `https://developer.android.com/reference/androidx/work/WorkerParameters` representing a `https://developer.android.com/reference/androidx/work/WorkRequest` that can run in a process corresponding to the provided `https://developer.android.com/reference/android/content/ComponentName.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html workerClassName` | The fully qualified class name of the `https://developer.android.com/reference/androidx/work/ListenableWorker` to delegate to |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/ComponentName.html componentName` | The `https://developer.android.com/reference/android/content/ComponentName.html` that identifies the `RemoteService` that hosts the `https://developer.android.com/reference/androidx/work/WorkRequest`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/WorkerParameters` | A new instance of `https://developer.android.com/reference/androidx/work/WorkerParameters` |