skip to Main Content

I am using this library to crop images in Android Studio. My code works on my phone, but on the emulator when you need to select an image, I see message "no apps can perform this action". This message. Maybe the problem in my code?

userImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CropImage.activity().start(getContext(), SettingsFragment.this);
            }
        });

onActivityResult

@Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        CropImage.ActivityResult result = CropImage.getActivityResult(data);
        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
                imageUri = result.getUri();
                userImage.setImageURI(imageUri);
                uploadImage(imageUri);
            }
        } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
            Exception error = result.getError();
            Toast.makeText(getActivity(), error.toString(), Toast.LENGTH_SHORT).show();
        }
    }

I didn`t find any information to solve this problem. I tried give permission in manifest.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

2

Answers


  1. Try to install file manager on the emulator, as third party app to support the action.

    Login or Signup to reply.
  2. If you use scheme to start an app , your phone or simulator must have at least one app support your scheme. Otherwise you’ll get wrong result.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search