My android app uses ACTION_IMAGE_CAPTURE to ask an installed camera-app to take a photo for my app.
If there are more than one camera apps installed android presents a camera chooser where the user can choose
which camera app should take the shot.
Since android-11 only the preinstalled camera is available.
To work around this i need to explicitly whitelist additional camera apps.
My android app followed Android 11 (R) return empty list when querying intent for ACTION_IMAGE_CAPTURE and https://commonsware.com/blog/2020/08/16/action-image-capture-android-r.html to whitelist the additional camera app OpenCamera for android-11 and later.
When executing my app on a android-10 device all works as expected.
When executing my app on a android-11 device i get ActivityNotFoundException
Any idea what i am missing?
Here is the sourcecode (from GetDocument2CameraActivity )
    private static final String[] AO11_ADDITIONAL_KNOWN_CAMERA_APPS = new String[] {
            "net.sourceforge.opencamera", // https://sourceforge.net/p/opencamera/code
    };
    private void onRequestPhoto() {
        this.resultPhotoUri = createSharedUri();
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
                .putExtra(MediaStore.EXTRA_OUTPUT, this.resultPhotoUri)
                .putExtra(MediaStore.EXTRA_MEDIA_TITLE, getString(R.string.label_select_picture))
                .setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION );
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            addInitialIntents(intent, AO11_ADDITIONAL_KNOWN_CAMERA_APPS);
        }
        // start the image capture Intent
        startActivityForResult(intent, ACTION_REQUEST_IMAGE_CAPTURE);
//!!!  startActivityForResult throws ActivityNotFoundException
    }
    private void addInitialIntents(Intent baseIntent, String... packageIdCandidates) {
        PackageManager packageManager = this.getPackageManager();
        List<Intent> whitelist = new ArrayList<>();
        for (String packageId : packageIdCandidates) {
            Intent candidate = new Intent(baseIntent).setPackage(packageId);
            List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(candidate, 0);
            if (!resolveInfos.isEmpty()) {
                Log.i(TAG, "known camera app added '" + packageId + "' = " + resolveInfos.get(0));
// this code is executed: logcat contains
// known camera app added 'net.sourceforge.opencamera' = ResolveInfo{37e3009 net.sourceforge.opencamera/.MainActivity m=0x108000}
                whitelist.add(candidate);
            }
        }
        if (!whitelist.isEmpty()) {
            baseIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, whitelist.toArray(new Intent[0]));
        }
    }
build.xml has compileSdk 31
Manifest contains
<queries>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
</queries>
when executing logcat contains
03-03 12:47:09.380 14898 14898 I k3b.camerafolder: known camera app added 'net.sourceforge.opencamera' = ResolveInfo{37e3009 net.sourceforge.opencamera/.MainActivity m=0x108000}
...
--------- beginning of crash
03-03 12:47:09.388 14898 14898 E AndroidRuntime: FATAL EXCEPTION: main
03-03 12:47:09.388 14898 14898 E AndroidRuntime: Process: de.k3b.android.camerafolder.debug, PID: 14898
03-03 12:47:09.388 14898 14898 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{de.k3b.android.camerafolder.debug/de.k3b.android.camerafolder.GetDocument2CameraActivity}: 
    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 clip={text/uri-list hasLabel(0) {U(content)}} (has extras) }
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3635)
...
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at android.app.Activity.startActivityForResult(Activity.java:5361)
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at de.k3b.android.camerafolder.GetDocument2CameraActivity.onRequestPhoto(GetDocument2CameraActivity.java:126)
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at de.k3b.android.camerafolder.GetDocument2CameraActivity.onCreate(GetDocument2CameraActivity.java:86)
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:8050)
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:8030)
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
03-03 12:47:09.388 14898 14898 E AndroidRuntime:        ... 12 more
for details see https://github.com/k3b/CameraFolder/issues/5