codelab-android-workmanager icon indicating copy to clipboard operation
codelab-android-workmanager copied to clipboard

Use of MediaStore in SaveImageToFileWorker.kt throws an exception

Open BlueImpS opened this issue 4 years ago • 1 comments

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

BlueImpS avatar Jan 11 '22 23:01 BlueImpS

Please check if you have given storage permission.

jhasan95 avatar Jan 19 '22 15:01 jhasan95