Reputation: 875
I have to throw in the towel on this. I am trying to use Image Cropper: Arthur Hub in a Fragment and I keep getting this
error: onActivityResult(int,int,Intent) in ProfileFragment cannot override onActivityResult(int,int,Intent) in Fragment attempting to assign weaker access privileges; was public
Here is the imageCropper function in the fragment:
private void ImagePicker() {
CropImage.activity(mainImageUri)
.setGuidelines(CropImageView.Guidelines.ON)
.setAspectRatio(1, 1)
.start(startActivityForResult();,this);
}
And here is the onActivityResult in the same fragment I am using to obtain the image:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == Activity.RESULT_OK) {
mainImageUri = result.getUri();
profileImage.setImageURI(mainImageUri);
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
}
}
}
I had this implemented previously in an activity and it worked fine. As soon as I adjusted it to work in a Fragment, I cannot proceed.
Upvotes: 1
Views: 860
Reputation: 13609
In fragment overrides onActivityResult
like this:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { //note: public, not protected.
super.onActivityResult(requestCode, resultCode, data);
}
and in fragment call startActivityForResult
method.
Upvotes: 0