ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 3 - Associate Android Developer discussion

Report
Export

Select correct demonstration of WorkRequest cancellation.

A.
workManager.enqueue(OneTimeWorkRequest.Builder(FooWorker::class.java).build())
Answers
A.
workManager.enqueue(OneTimeWorkRequest.Builder(FooWorker::class.java).build())
B.
val request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request)val status = workManager.getWorkInfoByIdLiveData(request.id) status.observe(...)
Answers
B.
val request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request)val status = workManager.getWorkInfoByIdLiveData(request.id) status.observe(...)
C.
val request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request) workManager.cancelWorkById(request.id)
Answers
C.
val request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request) workManager.cancelWorkById(request.id)
D.
val request1: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() val request2: WorkRequest = OneTimeWorkRequest.Builder(BarWorker::class.java).build() val request3: WorkRequest = OneTimeWorkRequest.Builder(BazWorker::class.java).build() workManager.beginWith(request1, request2).then(request3).enqueue()
Answers
D.
val request1: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() val request2: WorkRequest = OneTimeWorkRequest.Builder(BarWorker::class.java).build() val request3: WorkRequest = OneTimeWorkRequest.Builder(BazWorker::class.java).build() workManager.beginWith(request1, request2).then(request3).enqueue()
E.
val request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request) workManager.cancelWork(request)
Answers
E.
val request: WorkRequest = OneTimeWorkRequest.Builder(FooWorker::class.java).build() workManager.enqueue(request) workManager.cancelWork(request)
Suggested answer: C

Explanation:

Videos:

Working with WorkManager, from the 2018 Android Dev Summit

WorkManager: Beyond the basics, from the 2019 Android Dev Summit

Reference: https://developer.android.com/reference/androidx/work/WorkManager?hl=en

asked 18/09/2024
Anna Pytka
32 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first