Android-Image-Cropper
Android-Image-Cropper copied to clipboard
CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE is not working in fragment
yeah, for me too!:( Did you find any solution, mate?
Yes also not working for me
I have tried couple of times then stop trying using it inside fragment. In Activity it just works like charm, no issues. But in Samsung Galaxy J7 I found an issue of crashing camera app every time.
Solved it
public void selectImage(){
Intent intent = CropImage.activity()
.setGuidelines(CropImageView.Guidelines.ON)
.setAspectRatio(35,50)
.getIntent(getContext());
startActivityForResult(intent, CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE);
}
@Override
public 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 == RESULT_OK) {
Uri imageUri = result.getUri();
InputStream inputStream;
try {
inputStream = getActivity().getContentResolver().openInputStream(imageUri);
Bitmap photo = BitmapFactory.decodeStream(inputStream);
image1.setImageBitmap(photo);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Toast.makeText(getActivity(), "Cropping failed: " + result.getError(), Toast.LENGTH_LONG).show();
}
}else {
Toast.makeText(getActivity(), ""+requestCode, Toast.LENGTH_SHORT).show();
}
}
@CallieMuch Thanks a lot man. I tested your code and it works. @emondd4 please close the issue if this solutions worked for you. Cheers guys!:)
Is this working for everyone with Android R?
@CallieMuch thanks man your code is working but when you select camera it's not working
@CallieMuch thanks man your code is working but when you select camera it's not working
Are you using a Samsung Device? Mine is not working on Samsung Galaxy Model. Camera kept crashing:(
Hey!
I start a new project to handover this library https://github.com/CanHub/Android-Image-Cropper
The ideia is that we keep improving because this project don’t have updates since 2018
Hope I can count with your help.
Open to contribute, next pieces of work will be Android 11 permissions, refactor into Kotlin and ActivityContract
Hey!
I start a new project to handover this library https://github.com/CanHub/Android-Image-Cropper
The ideia is that we keep improving because this project don’t have updates since
2018
Hope I can count with your help.Open to contribute, next pieces of work will be Android 11 permissions, refactor into Kotlin and ActivityContract
Thanks for the help. I will use this in my next project. HOPE so.
I add a wiki how to migrate if you want, really easy @MuhammadArslan786