Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Use DownloadManager

The student materials have been reviewed and are updated as of SEPTEMBER 2022.

Replace the WorkManager usage when downloading images, with the DownloadManager, to display download progress.


Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

You’ve upgraded the starter project with a lot of fun features, using the WorkManager. One of the key features of the project is downloading images. and the simplest way to download an image is to use an HTTP connection manually.

val constraints = Constraints.Builder()

val localImageCheckWorker = OneTimeWorkRequestBuilder<LocalImageCheckWorker>()
    .setInputData(workDataOf("image_path" to imageUrl))

val workManager = WorkManager.getInstance(requireActivity())

val isDownloaded = workInfo.outputData.getBoolean("is_downloaded", false)

if (!isDownloaded) {
  val file = File(requireContext().externalMediaDirs.first(), imageUrl)
val request = DownloadManager.Request(Uri.parse("$BASE_URL/files/$imageUrl"))
    .setTitle("Image download")
val downloadManager = requireContext().getSystemService(