android / android/codelab-android-workmanager

Use of MediaStore in SaveImageToFileWorker.kt throws an exception

Open
#274 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
557
Forks
242
PR merge metrics
No merged PRs in 30d

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

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.