Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
com.android.camera.action.CROP stucks_Android_Android Intent_Crop - Fatal编程技术网

com.android.camera.action.CROP stucks

com.android.camera.action.CROP stucks,android,android-intent,crop,Android,Android Intent,Crop,我开始有以下意图: Intent cropIntent = new Intent("com.android.camera.action.CROP"); cropIntent.setDataAndType(data.getData(), "image/*"); cropIntent.putExtra("crop", "true"); cropIntent.putExtra("outputX", wall

我开始有以下意图:

            Intent cropIntent = new Intent("com.android.camera.action.CROP");
            cropIntent.setDataAndType(data.getData(), "image/*");
            cropIntent.putExtra("crop", "true");
            cropIntent.putExtra("outputX", wallWidth);
            cropIntent.putExtra("outputY", wallHeight);
            cropIntent.putExtra("aspectX", wallWidth);
            cropIntent.putExtra("aspectY", wallHeight);
            cropIntent.putExtra("scale", true);
            cropIntent.putExtra("scaleUpIfNeeded", true);
            cropIntent.putExtra("return-data", true);
            cropIntent.putExtra("noFaceDetection", true);
在我的例子中,墙宽和墙高是960/800,然后在裁剪时,这一意图受阻(这个加载循环一直旋转)。 如果我输入大约400或更少的输出,它工作得很好。
我怎样才能解决这个问题?因为我想有一个更高分辨率的位图作为输出。

大图片使用Uri,小图片使用位图。这里您需要使用Uri

关键代码如下:

private静态最终字符串图像\u文件\u位置=”file:///sdcard/temp.jpg";//临时文件
私有Uri imageUri=Uri.parse(图像文件位置)//存储大位图的Uri
startPhotoZoom(data.getData());
公共无效startPhotoZoom(Uri){
Intent Intent=newintent(“com.android.camera.action.CROP”);
intent.setDataAndType(uri,“image/*”);
意图。额外(“作物”、“真实”);
intent.putExtra(“aspectX”,1);
意图.putExtra(“aspectY”,1);
意图。putExtra(“比例”,真实);
意向。额外(“输出”,500);
意向。额外投入(“产出”,500);
intent.putExtra(“noFaceDetection”,true);
intent.putExtra(“返回数据”,false);
intent.putExtra(MediaStore.EXTRA_输出,imageUri);
intent.putExtra(“outputFormat”,Bitmap.CompressFormat.JPEG.toString());
startActivityForResult(意向、恒定、裁剪图像);
}
位图位图=解码后的位图(imageUri);
//解码位图
专用位图解码SBITMAP(Uri){
位图=空;
试一试{
位图=BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
}catch(filenotfounde异常){
e、 printStackTrace();
返回null;
}
返回位图;

}
Android没有
CROP
Intent
:我知道,但有些智能手机有,但“some”不是“all”。如果您的目标是让应用程序能够兼容大多数Android设备,请不要依赖未记录的、不受支持的
Intent
操作。使用库或实现自己的图像裁剪UI。是的,我创建了自己的裁剪UI,但只有在上述意图不存在时才会启动。你不知道我的问题的答案吗?你问题的答案是停止使用
意图
动作。即使设备具有支持它的活动,该活动也可能无法正常工作。设备制造商通常会加大对记录的和受支持的操作的支持力度(例如,
ACTION\u IMAGE\u CAPTURE
)。未记录和不支持的操作的可靠性往往会更差。而且,既然你已经有了一个更好的替代方案集成到你的应用程序中,那就使用它吧。