我使用com.android.camera.action.CROP在使用相机拍照后进行裁剪。com.android.camera.action.CROP不适用于Android jelly bean 4.3吗?
下面是我的代码,它曾经在4.3之前工作。但现在,由于Android作物行动将你带到画廊(因为画廊是默认的作物),此裁剪方法失败(照片不保存到画廊)。
有没有人知道解决这个问题的方法。我在哪里可以使用裁剪从相机
我使用com.android.camera.action.CROP在使用相机拍照后进行裁剪。com.android.camera.action.CROP不适用于Android jelly bean 4.3吗?
下面是我的代码,它曾经在4.3之前工作。但现在,由于Android作物行动将你带到画廊(因为画廊是默认的作物),此裁剪方法失败(照片不保存到画廊)。
有没有人知道解决这个问题的方法。我在哪里可以使用裁剪从相机
复制从一个类似的问题,刚才问的答案拍摄的照片..
你有没有考虑只使用一个图书馆像这样的:
我发现com.android.camera.action.CROP的行为有时可能会不同于手机,并且并不总是可用,所以如果您想要发布它,它可能会给您带来一些问题。
UPDATE:
我已经测试了上述库与Android 4.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();
}
如何将项目添加为Android Studio中的库? –
该库只允许您为应用程序使用设置内存,因此您将无法裁剪大尺寸图像。你仍然可以使用4.3上显示的标准android意图在这里http://stackoverflow.com/a/19435016/1499064 –
@JohnBale你必须在主目录下创建一个libs文件夹,然后将其添加到你的build.gradle文件 – Ankit
根据@commonsware 's post
这个意图是基于AOSP camera app
这可能会或可能不会在目标设备可用,对于一些4.3设备也可工作,而一些人不会。
所以更好的方法是使用找到的任何开源库at Android arsenal
(确保它们也不基于AOSP
)。
有没有人有任何证据证明它不适用于“某些设备?”另外,我们在这里讨论的是哪些设备?三星,HTC? – John61590
我已经尝试了几个收割机。特别是commonsware所提及的不是很好。例如,元信息中旋转数据拍摄的图片旋转不良。我发现这个:https://android-arsenal.com/details/1/3487和它的伟大。注意:确保你添加了一个操作栏主题的活动!
包含此库:https://github.com/lvillani/android-cropimage – g00dy
对于作物的方法 - 你可以在这里看看 - > http://stackoverflow.com/questions/17930577/android-4- 3-crop-gallery-resultcode-cancel – g00dy