Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): Provide a file name when an image is saved to the gallery to prevent app crash #3331

Merged
merged 4 commits into from
Jul 27, 2020

Conversation

iphilgood
Copy link
Contributor

Hi guys

I ran into an app crash with my ionic app after creating 32 images and save them into the gallery (saveToGallery: true in CameraOptions) 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?

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks!

@jcesarmobile jcesarmobile merged commit a7b9320 into ionic-team:2.x Jul 27, 2020
@iphilgood iphilgood deleted the fix-android-camera-crash branch July 28, 2020 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants