I want to allow the user to select a photo and crop the image. This is working most of the time. The problem I am having is that the App Chooser is showing apps that do not have cropping abilities.

enter image description here For example this is the App Chooser that comes up. However only the "Gallery" has the ability to crop.

So I need a way to filter the other three apps. Otherwise my users will get confused and angry.

Here is the code I am using currently:

            final Intent intent = new Intent(Intent.ACTION_PICK, 
                android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
        intent.setType("image/*");
        intent.putExtra("crop", "true");
        intent.putExtra("scale", true);
        intent.putExtra("outputX", 50);
        intent.putExtra("outputY", 68);
        intent.putExtra("aspectX", 50);
        intent.putExtra("aspectY", 68);
        intent.putExtra("return-data", true);
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)), SELECT_IMAGE);
        } else {
            //Show error
        }
有帮助吗?

解决方案

However only the "Gallery" has the ability to crop.

Only on some devices. There is no requirement, AFAIK, for a gallery app to offer some sort of cropping capability.

So I need a way to filter the other three apps

No, you need to realize that there is no cropping ability that is officially part of Android. Then, you need to implement cropping inside of your app. This is covered in greater detail in a blog post of mine that baronS mentioned in a comment.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top