简体   繁体   English

挑选图片来自图库的问题

[英]Issue in Picking image From gallery

I am using following code to pick image from gallery 我正在使用以下代码从图库中选择图像

public void takePhotoFromLibrary() {
        _isFromLogin = false;
        try {
            // Launch picker to choose photo for selected contact

            Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
            intent.setType("image/*");
//          intent.putExtra("crop", "true");
            intent.putExtra("aspectX", 1);
            intent.putExtra("aspectY", 1);
            intent.putExtra("outputX", 200);
            intent.putExtra("outputY", 200);
            intent.putExtra("scale", true);
            intent.putExtra("return-data", true);
            intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG
                    .toString());
            intent.putExtra("noFaceDetection", false);


            startActivityForResult(intent, PHOTO_PICKED);
        } catch (ActivityNotFoundException e) {
            e.printStackTrace();
        }
    }

I am using Lg optimus p350 for testing. 我正在使用Lg optimus p350进行测试。 In this case when i select an image picked by camera onActivityForResult is not getting called. 在这种情况下,当我选择摄像机拍摄的图像onActivityForResult没有被调用。 Can anyone please help me with this? 有人可以帮我这个吗?

If you use this intent instead to launch the pick image activity: 如果您使用此意图来启动选择图像活动:

Intent i = new Intent(Intent.ACTION_PICK, Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, PICK_IMAGE_REQUEST_CODE);

Then you will get a callback to: 然后你会得到一个回调:

@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent intent) { }

when the user has selected an image. 当用户选择了图像时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM