1

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. In this case when i select an image picked by camera onActivityForResult is not getting called. Can anyone please help me with this?

PgmFreek
  • 6,374
  • 3
  • 36
  • 47

2 Answers2

3

It may be help you..

http://android-er.blogspot.com/2011/02/select-image-using-android-build-in.html

How to pick an image from gallery (SD Card) for my app?

Community
  • 1
  • 1
anddev
  • 3,144
  • 12
  • 39
  • 70
1

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.

TofferJ
  • 4,678
  • 1
  • 37
  • 49