Skip to content

[image_picker] canTakePhotos returns false when targeting API 30 #85599

@kinex

Description

@kinex

It seems this check in ImagePickerDelegate.java does not work in Android 11:

private void launchTakeImageWithCameraIntent() {
.
.
.
    boolean canTakePhotos = intentResolver.resolveActivity(intent);

    if (!canTakePhotos) {
      finishWithError("no_available_camera", "No cameras available for taking pictures.");
      return;
    }

I have tested this in an emulator (API 30) and it throws the error "no_available_camera". If I comment out that code, I can take a photo with the emulator normally. Also one user has already reported me an issue he cannot take photos in my app with his Pixel 3 / Android 11 (my app targets API 30).

I think the issue is related to this:
https://stackoverflow.com/questions/62535856/intent-resolveactivity-returns-null-in-api-30

So the issue is here:

        new IntentResolver() {
          @Override
          public boolean resolveActivity(Intent intent) {
            // this check does not work in API 30
            return intent.resolveActivity(activity.getPackageManager()) != null;
          }
        },

image_picker: ^0.8.1+2

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 2.2Found to occur in 2.2found in release: 2.3Found to occur in 2.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: image_pickerThe Image Picker plugin.packageflutter/packages repository. See also p: labels.platform-androidAndroid applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions