Problem Description:
Take photo----photo------save, when returned to Onactivityresult ResultCode is 0, invalid. I look at the picture storage situation, the shot is stored well, but there is no storage, the image becomes 0byte.
Reason:
private void Cropimageuri (URI uri, int requestcode) {
Intent Intent = new Intent ("Com.android.camera.action.CROP");
Intent.setdataandtype (URI, "image/*");
Intent.putextra ("Crop", "true");
Intent.putextra ("Aspectx", aspectx);
Intent.putextra ("Aspecty", aspecty);
Intent.putextra ("Outputx", OUTPUTX);
Intent.putextra ("Outputy", outputy);
Intent.putextra ("scale", true);
Intent.putextra (Mediastore.extra_output, URI);
Intent.putextra ("Return-data", false);
Intent.putextra ("OutputFormat", Bitmap.CompressFormat.JPEG.toString ());
Intent.putextra ("Nofacedetection", true); No Face Detection
Startactivityforresult (Intent, Requestcode);
}
When cut, the URI of the open picture is the same as the URI to save the picture, resulting in a conflict, resulting in the size of the image 0Byte after the cut is completed.
Workaround:
Method One: You can save the camera photo in another location, the Intent.setdataandtype (URI, "image/*"), the URI in the camera photo Luo saved path.
Law two: Intent.putextra (Mediastore.extra_output, Uri), the URI in the clip to save the path.
Summary: In short, is Intent.setdataandtype (URI, "image/*"), and Intent.putextra (Mediastore.extra_output, URI), the address of the URI must be different.
4.4 System, Photo-cropping, ResultCode return 0