androiduricropucrop

What is the meaning and how to get the sourceUri and destinationUri in uCrop Library by Yalantis?


I am creating an Image Cropper Activity. However, my app is not working. I do not know what is the sourceUri and destinationUri means in the builder pattern of the uCrop Library by Yalantis. How can we get or find the sourceUri and destinationUri?

I noticed the contributor in Github said that destinationUri is " where you store the Uri. But how can we get the location to store it? For the sourceUri, I getIntent from another activity to get the imageUri.

I get the imageUri from another activity and I make it as the sourceUri. Please kindly correct me and my mistakes. Thank you very much.

File tempFile = new File (String.valueOf(getIntent().getParcelableExtra("ImageUri")));
File tempCropped = new File(getCacheDir(),"tempImgCropped.png");
Uri sourceUri = Uri.fromFile(tempFile);
Uri destinationUri = Uri.fromFile(tempCropped);


UCrop.of(sourceUri,destinationUri)
    //.withAspectRatio(1,1)
    //.withMaxResultSize(40,40)
      .start(this);

I hope that I can get to know what is the meaning of sourceUri and destinationUri and how to get those Uri.


Solution

  • How can we get or find the sourceUri and destinationUri?

    The sourceUri as you mentionned is retrieved through your Intent's extras, and it represents the PATH to the image that you are working on.

    The destinationUri means the PATH where you want to save your cropped image. It can be on the external storage or anywhere you decide to.