jaydeepw / poly-picker

Android library project for providing multiple image selection from the device.
406 stars 114 forks source link

Some mobile phone have a exception when take a picture。 #22

Closed HarlonWang closed 9 years ago

HarlonWang commented 9 years ago

Some mobile phone have a exception when take a picture。 java.lang.IllegalStateException: Unable to create new file: /storage/sdcard0/DCIM/Camera/1418805137509.jpg

cause this code :String path = MediaStore.Images.Media.insertImage(getActivity().getContentResolver(), bitmap, getPhotoFilename(), null);

I think this exception maybe with some mobile phone sdcard path diffenrent

could you help me to solve this question, thanks a lot.

jaydeepw commented 9 years ago

I would really love to help you here. The problem is I am not checking if the SDcard is preset of not.

Here is a gist of how it should be handled. I can review and merge if you send me a PR. http://stackoverflow.com/questions/13633308/android-contentresolver-insert-crashes-with-unable-to-create-new-file

HarlonWang commented 9 years ago

Thank you for your reply, but I now encountered a new problem, when I finished take a picture, time to enter, the photo album appeared two times before.

jaydeepw commented 9 years ago

Yes, I have noticed that on some phones. That is because image orientation is being corrected after taking the picture. Which device are you using?

HarlonWang commented 9 years ago

Mi(www.mi.com) phone at China ,perhaps you didn't hear about it , And other China Phone have same problem

jaydeepw commented 9 years ago

Yes. I know about Mi. We have a lot of buyers of Mi in India too. However, I cannot test on that device as I dont have the device with me. Capturing and storing the image may take time but does it crash other than what you have reported earlier?

HarlonWang commented 9 years ago

I tried several different ways to insert image,I think its may about with EXTERNAL_CONTENT_URI And
INTERNAL_CONTENT_URI

jaydeepw commented 9 years ago

Yes, defintely it is about that. So if the SDCard is mounted the image should be stored on EXTERNAL_CONTENT_URI otherwise if the device has sufficient storage, it should be stored on INTERNAL_CONTENT_URI. If the device does not have enough space, we should show some message to the user.

HarlonWang commented 9 years ago

you are right,Thank you code again, its very helpful for me. my english is not good.and thank you answer again.

jaydeepw commented 9 years ago

Welcome Jack. Submit a Pull Request when you are done editing the code. Please make sure you keep the code consistent. I will review and merge it.

HarlonWang commented 9 years ago

of course ,If I can solve this ,I have the honor of send a PR .

jaydeepw commented 9 years ago

:+1:

jaydeepw commented 9 years ago

I tested the sample app that uses the latest version (vv1.0.11 at the time of writing) on Mi Redmi and found it working flawlessly. Anything specific I should do to reproduce the crash?

Let me know, I will close the issue otherwise.