Question

It seems dublicate but it is not please look my question.

I ve searched many times on google and stackoverflow. I found many examples but none of it does not solve my issue.

What I need is :

I want to capture image and save it (I give the path) After that I want to crop it and save it same place(I mean replace the original file with cropped image)

What I did is:

I use this for take image:

 Intent cameraIntent = new Intent( MediaStore.ACTION_IMAGE_CAPTURE); 
 cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); // outputFileUri is my path
 startActivityForResult(cameraIntent, TAKE_PHOTO_CODE); 

For the crop the image I use this sample on stackoverflow :

this

What is done:

I capture the image and after capture I run the crop image method and it is fine as well.

After I done with crop the image I cant see the cropped image , it is just captured image.

What is the issue:

There is no error but I want to see captured image will be replaced with the original captured image.

thanks in advance!!

Was it helpful?

Solution

Try this, onActivityResult you will Returned data

  @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // TODO Auto-generated method stub
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {


    case Utils.CROP_IMAGE:
        if (resultCode == RESULT_OK) {
            // Create an instance of bundle and get the returned data
            try {
                Uri outputFileUri = data.getData();
                             String path = getRealPathFromURI(outputFileUri)

            } catch (Exception e) {
                // TODO: handle exception
            }
        }
        break;

    default:
        break;
    }
}

Get file path fome URI.

 public String getRealPathFromURI(Uri contentUri) 
 {
 String[] proj = { MediaStore.Audio.Media.DATA };
 Cursor cursor = managedQuery(contentUri, proj, null, null, null);
 int column_index = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
 cursor.moveToFirst();
 return cursor.getString(column_index);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top