Open PrafulAnand opened 7 years ago
Sir I tested multimager apk directly on my device 5.1 api 22(lyf mobile phone flame seven) the same issue persists so I think something is really messing up the camera fragment most probably I guess.... When the multi capture button is clicked the camera opens but as soon as I click the photo the app crashes and redirects to main screen.... Not able to solve it
Almost unable to replicate this too. I do not have a real device with version 5.1 exactly. I have tested on a device with version 5.1.1 and all emulators but its all working good. Probably the reason is mentioned in the crash report mentioned above. I have added a try catch for a fail case. I believe the issue is with the "fileUri" using which we are trying to get the real path of the image captured in the method "getImageRealPathFromURI()". I have provided logs at various places to check the value of "fileUri" object. Else you can debug to check its value. Please upgrade to version 1.0.6 after some time.
OK so how to get around this problem.... After checking the logs
Exception in photoCallback
java.io.FileNotFoundException: : open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileOutputStream.
this error in my device running on 5.1 api 22 after you updated the repo....( I am using 1.0.6 multimager version)
That is obvious. If you can check the source code for CameraFragment
class, the issue is with the getImageRealPathFromURI()
method. We are trying to query the full image path from the newly created fileUri
but in your device the query returns zero results. Hence a blank path is returned which cannot be saved by the SavePhotoTask
async class.
I would suggest you should write a small application first to replicate the process of inserting a image data into MediaStore.Images table and querying it back using the fileUri.
Simply put, please check if the getOutputMediaFile()
method produces a valid File object for you. If this works in your device, then the library should work too.
Could you suggest some more detail I am not able to get around this problem why it's arriving in this 5.1 api only...
I have tested in some other devices running 5.1 and 5.1.1 too but it is working good there. Only in the case of Lyf phones running 5.1 i am seeing this error. I have tested here with a Lyf phone model number LS 4005 showcased as Flame. Unfortunately it has no adb drivers to debug using the device.
But as i stated, the getOutputMediaFile()
method is creating the problem. The approach used here is a very standard one, that i have used for most of my applications(finally put through as this library).
On a personal note @PrafulAnand , you can do one thing. While creating the ContentValues
object for inserting a media record, you can input the full path too along with title. And finally use it to create file object.
For example the getOutputMediaFile()
method can be changed to as following:
private File getOutputMediaFile(){
String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmmss").format(new Date());
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, timeStamp + ".jpg");
File imageFile = new File(Environment.getExternalStorageDirectory(), timeStamp + ".jpg");
values.put(MediaStore.Images.Media.DATA, imageFile.getPath());
Uri fileUri = getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
return imageFile;
}
I am testing my app against different version beacause I have to launch it..Now i am able to open the camera and as soon as I click the photo my app crashes.....Not able to fix the issue..error in android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 at android.database.AbstractCursor.checkPosition(AbstractCursor.java:426) at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) at android.database.CursorWrapper.getString(CursorWrapper.java:114) at com.vlk.multimager.activities.CameraFragment.getImageRealPathFromURI(CameraFragment.java:578) at com.vlk.multimager.activities.CameraFragment.getOutputMediaFile(CameraFragment.java:588) at com.vlk.multimager.activities.CameraFragment$5.onPictureTaken(CameraFragment.java:673) at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1102) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5354) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)