language features like Extension Functions, Lambda, etc. • Makes your code more concise • Note: This doesn’t add any new feature to existing Android APIs Android KTX (Kotlin Extensions)
execution • Job Scheduler Api supports Api >=21 • Firebase Job Dispatcher comes with backward compatibility upto Api level 14, but requires, Google Play Services
Applying filters to images and saving the image • Periodically syncing local data with the network • Note: SHOULD NOT use work manager to make api calls that should only work while in Foreground. We have ThreadPool for such Tasks.
work // Enqueue your work WorkManager.getInstance() .enqueue(compressionWork) // Query work status with LiveData<WorkStatus> WorkManager.getInstance() .getStatusById(compressionWork.id) .observe(lifecycleOwner, Observer { workStatus -> // Do something with the status if (workStatus != null && workStatus.state.isFinished) { // ... } }) // Cancel your work WorkManager.getInstance() .cancelWorkById(compressionWorkId)