Application hangs when cropping image
I have the below crop method. When I call
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); my screen hangs at
'saving image'. If I don't call it, the cropped image is not written to
file.
private void crop() {
try {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(mImageCaptureUri, "image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", 4);
cropIntent.putExtra("aspectY", 3);
cropIntent.putExtra("outputX", 500);
cropIntent.putExtra("outputY", 300);
File f = new File(Environment.getExternalStorageDirectory(),
"/temporary_holder.jpg");
try {
f.createNewFile();
} catch (IOException ex) {
Log.e("io", ex.getMessage());
}
uri = Uri.fromFile(f);
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
startActivityForResult(cropIntent, PIC_CROP);
} // respond to users whose devices do not support the crop action
catch (ActivityNotFoundException anfe) {
// display an error message
String errorMessage = "Your device doesn't support the crop action!";
Toast toast = Toast
.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
No comments:
Post a Comment