Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Similar to #2 but replace it.
Tested on emulators with various versions, like 24, 28, 29, 30, 33, and a real device api 27.
It gives really good results with
MediaScannerConnection.scanFile
for a file written to the app external media dir (<external>/Android/media/<app-id>
).While MediaStore insert was not working as expected for 30 to 33, not adding the media to the gallery, and instead creating an empty entry ; for api 29 and before, results were correct but not as consistent as expected.
The Intent
ACTION_MEDIA_SCANNER_SCAN_FILE
is deprecated and is not effective anymore.See https://developer.android.com/reference/android/content/Intent#ACTION_MEDIA_SCANNER_SCAN_FILE
+ prevent continue after Invalid File Path error