I am new to Android development and I tried my best to pick an image from gallery and saving within the app after cropping but I failed. Please help me to solve this issue. I tried to mix up different codes but nothing is working for me.
if (resultCode == RESULT_OK) {
//Uri photoUri = data.getData();
//if (photoUri != null) {
// photoPickerIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);
CropImage.activity(android.net.Uri.parse(data.getDataString()))
.setAspectRatio(1,1)
.setFixAspectRatio(true)
.start(activity);
CropImage.ActivityResult result1 = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
iv.setImageURI(result1.getUri());
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result1.getError();
Log.d(TAG, "onActivityResult: " + error.getMessage());
}
//currentImage = MediaStore.Images.Media.getBitmap(this.getContentResolver(), photoUri);
//selectedImage.setImageBitmap(currentImage);
// }