Skip to content

Commit 8b6182a

Browse files
author
Jill Heske
committed
Step.08-Exercise-Schedule-Background-Work
1 parent 93e8a8b commit 8b6182a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

app/src/main/java/com/example/android/devbyteviewer/DevByteApplication.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ import timber.log.Timber
2525
*/
2626
class DevByteApplication : Application() {
2727

28+
// TODO (01) Create CoroutineScope variable applicationScope, using Dispatchers.Default.
29+
30+
// TODO (02) Create a delayedInit() function that calls setupRecurringWork() in
31+
// the coroutine you defined above.
32+
33+
// TODO (04) Create a setupRecurringWork() function and use a Builder to define a
34+
// repeatingRequest variable to handle scheduling work.
35+
36+
// TODO (05) In setupRecurringWork(), get an instance of WorkManager and
37+
// launch call enqueuPeriodicWork() to schedule the work.
38+
39+
// TODO (07) In setupRecurringWork(), define constraints to prevent work from occurring when
40+
// there is no network access or the device is low on battery.
41+
42+
// TODO (08) Add the constraints to the repeatingRequest definition.
43+
2844
/**
2945
* onCreate is called before the first screen is shown to the user.
3046
*
@@ -34,5 +50,6 @@ class DevByteApplication : Application() {
3450
override fun onCreate() {
3551
super.onCreate()
3652
Timber.plant(Timber.DebugTree())
53+
// TODO (03) Call delayedInit().
3754
}
3855
}

app/src/main/java/com/example/android/devbyteviewer/work/RefreshDataWork.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import retrofit2.HttpException
2626

2727
class RefreshDataWorker(appContext: Context, params: WorkerParameters):
2828
CoroutineWorker(appContext, params) {
29+
30+
// TODO (06) Create a companion object and define a WORK_NAME constant.
31+
2932
/**
3033
* A coroutine-friendly method to do your work.
3134
*/

0 commit comments

Comments
 (0)