fix(android): Provide a file name when an image is saved to the gallery to prevent app crash #3331
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.
Hi guys
I ran into an app crash with my ionic app after creating 32 images and save them into the gallery (
saveToGallery: true
inCameraOptions
) on Android 10. I could reproduce it on a Pixel 3a Emulator running Android 10 and several other physical devices running Android 10.This fix extracts the file name from the file path. This file name should be unique since it is generated from the timeStamp of when the picture was taken (thanks @jcesarmobile).
As you can see here the name of the image is set to "Image" when no name argument was passed. I think this is where the problem starts and after that numbers get appended internally and somehow stop working after 32 images 😅 .
I've also made tests on a Sony device running Android 9. I found out that the saved image in the gallery has somehow no meta data and it's displayed at the bottom of the gallery. There are also several Stack Overflow threads (e.g. here) which describe this exact problem. I know this would be a different fix but does anybody know how this should be done in a right way?