应用程序在裁剪图像时挂起

时间:2013-08-12 14:09:44

标签: android

我有以下裁剪方法。当我拨打cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);时,我的屏幕会挂起“保存图片”。如果我不调用它,则裁剪的图像不会写入文件。

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();
}

}

1 个答案:

答案 0 :(得分:0)

我有同样的问题,它坚持: cropIntent.putExtra(“outputX”,500); ..这么糟糕,修复这个问题的唯一方法是去除电池..

但如果我服用 cropIntent.putExtra(“outputX”,200);它工作得很好..

(设备HTC Sensation Z710e Android 4.0.3(API 15))