ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 65 - Associate Android Developer discussion

Report
Export

"workManager" is an instance of WorkManager. Select correct demonstration of WorkRequest cancellation:

A.
workManager.enqueue(new OneTimeWorkRequest.Builder(FooWorker.class).build());
Answers
A.
workManager.enqueue(new OneTimeWorkRequest.Builder(FooWorker.class).build());
B.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(request.getId()); status.observe(...);
Answers
B.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);LiveData<WorkInfo> status = workManager.getWorkInfoByIdLiveData(request.getId()); status.observe(...);
C.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);workManager.cancelWorkById(request.getId());
Answers
C.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request);workManager.cancelWorkById(request.getId());
D.
WorkRequest request1 = new OneTimeWorkRequest.Builder(FooWorker.class).build();WorkRequest request2 = new OneTimeWorkRequest.Builder(BarWorker.class).build(); WorkRequest request3 = new OneTimeWorkRequest.Builder(BazWorker.class).build(); workManager.beginWith(request1, request2).then(request3).enqueue();
Answers
D.
WorkRequest request1 = new OneTimeWorkRequest.Builder(FooWorker.class).build();WorkRequest request2 = new OneTimeWorkRequest.Builder(BarWorker.class).build(); WorkRequest request3 = new OneTimeWorkRequest.Builder(BazWorker.class).build(); workManager.beginWith(request1, request2).then(request3).enqueue();
E.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).build(); workManager.enqueue(request); workManager.cancelWork(request);
Answers
E.
WorkRequest request = new OneTimeWorkRequest.Builder(FooWorker.class).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
ERIC LUM
40 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first