Use of MediaStore in SaveImageToFileWorker.kt throws an exception

Open
#274 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
android, kotlin
Domain
mobile

Research direction

Start by reproducing the failure in SaveImageToFileWorker.kt and capture the exception, then read the MediaStore call and related flow in BlurActivity. Review issue 259 for related context. Done means the image is stored, outputImageUri is populated, and the See File button becomes visible.

Written by the indexing model from the issue text.

Description

In SaveImageToFileWorker.kt the code line

val imageUrl = MediaStore.Images.Media.insertImage(
                   resolver, bitmap, Title, dateFormatter.format(Date()))

throws an exception; hence no image is stored and no output is produced. As a result in BlurActivity the final check to activate the seeFileButton using the code

// If there is an output file show "See File" button
                if (!outputImageUri.isNullOrEmpty()) {
                    viewModel.setOutputUri(outputImageUri as String)
                    binding.seeFileButton.visibility = View.VISIBLE
                }

always fails

This may be related to issue 259

PS I am using android studio 2020.3.1 to compile and run

Dominant language
Kotlin
Stars
557
Forks
242
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from android/codelab-android-workmanager

All issues in android/codelab-android-workmanager

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.