【发布时间】:2016-03-10 10:34:55
【问题描述】:
在通过相机拍摄照片后裁剪照片时,我在棉花糖设备中遇到问题。 它在 6 版本以下的设备上运行良好。 这是我的代码:
if (requestCode == CAMERA_PICTURE) {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
// set data type to be sent , indicate image type and Uri of image
cropIntent.setDataAndType(mCapturedImageURI, "image/*");
List<ResolveInfo> list = getPackageManager().queryIntentActivities( cropIntent, 0 );
int size = list.size();
// handle the case if there's no cropper in the phone
if (size == 0) {
Toast.makeText(this, "Can not find image crop app", Toast.LENGTH_SHORT).show();
return;
} else {
//set crop properties
cropIntent.putExtra("crop", "true");
//indicate aspect of desired crop
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
//indicate output X and Y
cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);
String fileName = Ut.getDateTimeStamp();
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
mCropImageURI = getContentResolver()
.insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
values);
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT,
mCropImageURI);
//retrieve data on return
cropIntent.putExtra("return-data", true);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, CROP_PICTURE);
return;
}
} else if (requestCode == CROP_PICTURE) {
getCameraPhotoFromIntent(data);
setImagePathToSource();
}
【问题讨论】:
-
您使用哪个应用进行裁剪?
-
我正在使用“照片”默认应用在我的 Nexus 9 设备中使用裁剪
-
你必须向谷歌提出问题,你也可以查看日志。
-
是的,我注意到,“照片”应用程序正在崩溃,而不是我正在运行的应用程序。你能解释一下这个错误“mediaFileUri must be a File Uri”
标签: android android-camera android-6.0-marshmallow android-camera-intent illegalargumentexception