4

I recently updated my Poco X3 NFC 64GB test device to Android 11:

  • MIUI Global 12.0.8(RJGEUXM)
  • Android 11 RKQ1.200826.002

Ever since I am unable to take or pick photos in my app. On other Android 11 devices (and emulator) everything works fine. The app is compiled to API level 30.

I start the photo picker chooser like this:

private void pickPhoto() {
    Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
        startActivityForResult(intent, 100);
    }
}

This works fine, but after I have picked a photo it returns to the app, triggering onActivityResult with resultCode 0 (RESULT_CANCELED) and data is null too. On other Android 11 devices I can retrieve the photo from the data, but not on my Poco. Yes I did add the necessary query to the manifest file (else I wouldn't be able to open the picker in the first place).

When I try to fetch a photo from the camera I have exactly the same issue. Again on other Android 11 devices this works fine. So yes I did add and use the necessary file provider.

Sometimes a toast pops up about not having granted the right permissions. Do any of you guys have a Poco phone and like to try it out? I wonder if the Poco rom is just broken or something.

UPDATE

I've narrowed down the problem. It turns out that if startActivity() starts a camera/gallery activity directly it works fine. However if you're prompted a chooser first (e.g. because you have multiple gallery apps) it goes wrong.

So if you pick a gallery app and say to always use it in the future, the next time it will open that gallery app directly and then it works correctly.

If you use Intent.createChooser() it never works right. Even if it contains only one intent that is launched directly without prompting a chooser it fails to return a photo.

Can we agree that this is a MIUI bug?

Janneman
  • 1,093
  • 15
  • 23
  • `I did add the necessary query to the manifest file (else I wouldn't be able to open the picker in the first place).` What did you do? You can just use ACTION_PICK without anything in manifest. – blackapps Jun 01 '21 at 09:35
  • `On other Android 11 devices I can retrieve the photo from the data, ` You better show onActivityResult code. – blackapps Jun 01 '21 at 09:36
  • For your camera issue. Post separate intent and another onActivityResult. – blackapps Jun 01 '21 at 09:37
  • `android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI` Why did you use that? Not needed. Remove. – blackapps Jun 01 '21 at 09:38
  • Removing EXTERNAL_CONTENT_URI results in the chooser showing file explorer and other apps, instead of just gallery apps. Picking a photo from the file explorer results in the same issue. – Janneman Jun 01 '21 at 09:42
  • How about ACTION_GET_CONTENT? – blackapps Jun 01 '21 at 09:44
  • The contents of onActivityResult are irrelevant, that works fine. The problem is that it gets called with result code CANCELLED instead of OK and Intent data is null instead of containing data like it normally does. Hence I just have nothing to work with. – Janneman Jun 01 '21 at 09:45
  • Yes using ACTION_GET_CONTENT directly opens some kind of document explorer. Picking a photo here works! It'd be nice if you could use a photo gallery instead though. – Janneman Jun 01 '21 at 09:55
  • Maybe by adding a chooser? – blackapps Jun 01 '21 at 10:20
  • I've added an update to my post. Turns out the chooser is actually the root of the problem. I am open to ideas... – Janneman Jun 01 '21 at 13:57
  • @Janneman Did you find a solution other than removing the chooser? Were you able to reproduce the issue on a non-MIUI device since then? – yasirkula Oct 27 '21 at 16:01
  • 2
    @yasirkula The issue is only present on my MIUI device (I don't have other ones to test on). I updated it to MIUI Global 12.5.2 but same issue. I can't find a way to detect if this issue occurs. For now I just check if a device is running MIUI 12.x and in that case it skips the chooser and just uses the first found camera/gallery app. So far I have no complaints of users. – Janneman Oct 27 '21 at 22:04
  • 1
    Just updated to MIUI 12.5.5 but still the same issue... – Janneman Feb 25 '22 at 09:27

0 Answers0