Intent cropIntent = new Intent("com.android.camera.action.CROP", null);包:"com.android.camera.action“并不是在所有的安卓设备(如Nexus7)中都可用。.Is没有任何代码来获取该安卓设备使用的”裁剪包“的名称。
发布于 2013-11-23 13:58:58
您检查过此Android 4.3 crop gallery resultCode Cancel吗
您有没有考虑过只使用这样的库:
https://github.com/biokys/cropimage
我发现com.android.camera.action.CROP有时会在不同的手机上表现不同,而且并不总是可用的,所以如果你想要发布它,它可能会给你带来一些问题。
更新:
我已经在Android4.3上测试了上面的库,没有任何问题。您只需将该库添加到您的项目中。
然后,您可以用非常类似的方式编写您的方法:
private void performCrop(Uri picUri) {
//you have to convert picUri to string and remove the "file://" to work as a path for this library
String path = picUri.toString().replaceAll("file://", "");
try {
int aspectX = 750;
int aspectY = 1011;
Intent intent = new Intent(this, CropImage.class);
//send the path to CropImage intent to get the photo you have just taken or selected from gallery
intent.putExtra(CropImage.IMAGE_PATH, path);
intent.putExtra(CropImage.SCALE, true);
intent.putExtra("aspectX", aspectX);
intent.putExtra("aspectY", aspectY);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCurrentPhotoPath)));
startActivityForResult(intent, CROP);
}
catch (ActivityNotFoundException anfe) {
String errorMessage = "Your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}}
https://stackoverflow.com/questions/20158929
复制相似问题