是com.android.camera.action.CROP没有可用于Android果冻豆4.3? [英] Is com.android.camera.action.CROP not available for Android jelly bean 4.3?

查看:174
本文介绍了是com.android.camera.action.CROP没有可用于Android果冻豆4.3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用com.android.camera.action.CROP使用相机拍摄PIC后裁剪。

I was using com.android.camera.action.CROP for cropping after taking pic using camera.

下面是我这用于4.3之前的早期工作code。

Below was my code which used to work earlier before 4.3.

Intent cropIntent = new Intent("com.android.camera.action.CROP");
                        cropIntent.setType("image/*");
                        cropIntent.putExtra("crop", "true");
                        cropIntent.putExtra("aspectX", 1);
                        cropIntent.putExtra("aspectY", 1);
                        cropIntent.putExtra("outputX", Conf.getInt("IMAGE_WIDTH"));
                        cropIntent.putExtra("outputY", Conf.getInt("IMAGE_HEIGHT"));
                        cropIntent.putExtras(extras);
                        startActivityForResult(cropIntent, CROP_REQUEST_CODE);

但现在由于Android作物动作把你带到画廊(因为画廊是默认的作物),这种种植方法失败(照片不会被保存到库)。

But now since android crop action takes you to gallery(because gallery is default with crop), this cropping method fails(photo is not saved to gallery).

还有没有人知道出路这个问题。我在哪里可以使用作物从相机拍摄的照片

Does any one knows a way out of this issue. Where I can use the crop on the photo taken from camera

推荐答案

复制从问过类似的问题的答案前面。

Copying the answer from a similar question asked earlier..

你有没有考虑只用像这样的库:

Have you considered just using a library like this one:

GitHubLink

我觉得com.android.camera.action.CROP有时可以表现不同,从电话到电话,并不总是可用的,所以它可能会导致一些问题,你无论如何,如果你正在寻找将其释放。

I find the com.android.camera.action.CROP can sometimes behave differently from phone to phone and is not always available, so it could cause some problems for you anyway if you are looking to release it.

更新:

我已经测试了Android 4.3以上的图书馆,它的工作原理没有问题。你只需要到库添加到项目中。

I have tested the above library with Android 4.3 and it works with no problem. You just need to add the library to your project.

然后,您可以在一个非常类似的方式编写方式:

You can then write your method in a very similar way:

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

这篇关于是com.android.camera.action.CROP没有可用于Android果冻豆4.3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆