Open sahujaunpuri opened 3 years ago
Hi,
Please try this:
//1. Create folder inside your app. Let's call it "folder_name": File mPhotoStorageFolder = getExternalFilesDir("folder_name");
//2. path and name for your target cropped file: String path = mPhotoStorageFolder + "/fileNmae" + ".jpg"; Uri mUriPath = Uri.parse(path);
//3. create below method for different schemes. You will use it soon: private Uri getRealUri(Uri sourceUri){ Uri mRealUri = null; if (sourceUri.getScheme() == null){ mRealUri = Uri.fromFile(new File(Objects.requireNonNull(sourceUri.getPath()))); }else{ mRealUri = sourceUri; } return mRealUri; }
//4. Then set it in the cropper's setOutputUri. You will use the above method here. CropImage.activity(imageUri) .setOutputUri(getRealUri(mUriPath)) .start(this);
//5. That's it! you can check the path on the cropped image in onActivityResult like this:
CropImage.ActivityResult result = CropImage.getActivityResult(data); String CroppedFilePath = result.getUri().getPath();
Hope this helps.
After cropping the image, it saves it to
"file:///data/user/0/package name/cache/croppedXYZ.jpg
.I want to save it in a folder named `Environment.getExternalStorageDirectory()
please guide me