TestListenableWorkerBuilder


class TestListenableWorkerBuilder<W : ListenableWorker?>

Known direct subclasses
TestWorkerBuilder

Builds instances of Worker which can be used for testing.


Builds instances of androidx.work.ListenableWorker which can be used for testing.

Parameters
<W : ListenableWorker?>

The actual ListenableWorker subtype being built.

Summary

Public functions

W

Builds the ListenableWorker.

java-static TestListenableWorkerBuilder<ListenableWorker!>
from(context: Context, workRequest: WorkRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

java-static TestListenableWorkerBuilder<W!>
<W : ListenableWorker?> from(context: Context, workerClass: Class<W!>)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

TestListenableWorkerBuilder<W!>

Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.

TestListenableWorkerBuilder<W!>
setId(id: UUID)

Sets the id for this unit of work.

TestListenableWorkerBuilder<W!>
setInputData(inputData: Data)

Adds input Data to the work.

TestListenableWorkerBuilder<W!>
@RequiresApi(value = 28)
setNetwork(network: Network)

Sets the network associated with this unit of work.

TestListenableWorkerBuilder<W!>

Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.

TestListenableWorkerBuilder<W!>
setRunAttemptCount(runAttemptCount: Int)

Sets the initial run attempt count for this work.

TestListenableWorkerBuilder<W!>

Sets the tags associated with this unit of work.

TestListenableWorkerBuilder<W!>

Sets the authorities for content Uri's associated with this unit of work.

TestListenableWorkerBuilder<W!>
@RequiresApi(value = 24)
setTriggeredContentUris(contentUris: (Mutable)List<Uri!>)

Sets the list of Content Uris associated with this unit of work.

TestListenableWorkerBuilder<W!>

Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.

Public functions

build

Added in 2.1.0
fun build(): W

Builds the ListenableWorker.

Returns
W

the instance of a ListenableWorker.

from

Added in 2.1.0
java-static fun from(context: Context, workRequest: WorkRequest): TestListenableWorkerBuilder<ListenableWorker!>

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

Parameters
context: Context

The Context

workRequest: WorkRequest

The WorkRequest

from

Added in 2.1.0
java-static fun <W : ListenableWorker?> from(context: Context, workerClass: Class<W!>): TestListenableWorkerBuilder<W!>

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

Parameters
context: Context

The Context

workerClass: Class<W!>

The subtype of ListenableWorker being built

Returns
TestListenableWorkerBuilder<W!>

The new instance of a ListenableWorker

setForegroundUpdater

Added in 2.3.0
fun setForegroundUpdater(updater: ForegroundUpdater): TestListenableWorkerBuilder<W!>

Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.

Parameters
updater: ForegroundUpdater

The ForegroundUpdater which can handle notification updates.

setId

Added in 2.1.0
fun setId(id: UUID): TestListenableWorkerBuilder<W!>

Sets the id for this unit of work.

Parameters
id: UUID

The UUID

setInputData

Added in 2.1.0
fun setInputData(inputData: Data): TestListenableWorkerBuilder<W!>

Adds input Data to the work.

Parameters
inputData: Data

key/value pairs that will be provided to the worker

setNetwork

Added in 2.1.0
@RequiresApi(value = 28)
fun setNetwork(network: Network): TestListenableWorkerBuilder<W!>

Sets the network associated with this unit of work.

Parameters
network: Network

The Network associated with this unit of work

setProgressUpdater

Added in 2.3.0
fun setProgressUpdater(updater: ProgressUpdater): TestListenableWorkerBuilder<W!>

Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.

Parameters
updater: ProgressUpdater

The ProgressUpdater which can handle progress updates.

setRunAttemptCount

Added in 2.1.0
fun setRunAttemptCount(runAttemptCount: Int): TestListenableWorkerBuilder<W!>

Sets the initial run attempt count for this work.

Parameters
runAttemptCount: Int

The initial run attempt count

setTags

Added in 2.1.0
fun setTags(tags: (Mutable)List<String!>): TestListenableWorkerBuilder<W!>

Sets the tags associated with this unit of work.

Parameters
tags: (Mutable)List<String!>

The List of tags to be used

setTriggeredContentAuthorities

Added in 2.1.0
@RequiresApi(value = 24)
fun setTriggeredContentAuthorities(authorities: (Mutable)List<String!>): TestListenableWorkerBuilder<W!>

Sets the authorities for content Uri's associated with this unit of work.

Parameters
authorities: (Mutable)List<String!>

The List of authorities

setTriggeredContentUris

Added in 2.1.0
@RequiresApi(value = 24)
fun setTriggeredContentUris(contentUris: (Mutable)List<Uri!>): TestListenableWorkerBuilder<W!>

Sets the list of Content Uris associated with this unit of work.

Parameters
contentUris: (Mutable)List<Uri!>

The list of content Uris

setWorkerFactory

Added in 2.1.0
fun setWorkerFactory(workerFactory: WorkerFactory): TestListenableWorkerBuilder<W!>

Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.

Parameters
workerFactory: WorkerFactory

The WorkerFactory to use to construct the androidx.work.ListenableWorker