uCrop icon indicating copy to clipboard operation
uCrop copied to clipboard

Both input and Output URI Must be Specified (AcitivityResultLauncher)

Open TeamRainless opened this issue 1 year ago • 0 comments

I'm using, essentially, a variation of the exact same code that everyone else is using since startActivityForResult is deprecated:

  ActivityResultLauncher<Intent> ucropActivityIntent = registerForActivityResult(
            new ActivityResultContracts.StartActivityForResult(),
            new ActivityResultCallback<ActivityResult>() {
                public void onActivityResult(ActivityResult result) {
                    if (result.getData() != null) {
                        Uri uri = UCrop.getOutput(result.getData());
                        startCropActivity(uri);
                    }
                }
            });

This loads the image picker and I choose my image, but as soon as I've picked the photo it takes me to the Activity where it throws the error: "Both input and OutPut URI Must Be Specified."

If I switch back to...

startActivityForResult(intent, 1);

...instead of:

ucropActivityIntent.launch(intent);

...it works just fine.

Don't know why it's working for everyone else but not for me.

Here's my startCropActivity:

    private void startCropActivity(@NonNull Uri uri) {
        String destinationFileName = SAMPLE_CROPPED_IMAGE_NAME;
        destinationFileName += ".jpg";
        UCrop uCrop = UCrop.of(uri, Uri.fromFile(new File(getCacheDir(), destinationFileName)));
        //uCrop = basisConfig(uCrop);
        uCrop = advancedConfig(uCrop);

        uCrop.start(MainActivity.this);
    }



TeamRainless avatar Jul 25 '22 15:07 TeamRainless