-1

On Android 10 and below, when I take a picture using the code below, everything is fine except for Android 11 and above.

private fun openCameraApp() {
        val photoURI: Uri = FileProvider.getUriForFile(
            this,
            "com.example.android.fileprovider",

        appFolder


    )
    refresh()
    val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI)
    println("::Camera result::  ${photoURI}")

    resultLauncher.launch(cameraIntent)
}
Ammar Abdullah
  • 802
  • 4
  • 8
  • 21
  • Does this answer your question? [Android 11 Capture image using Camera](https://stackoverflow.com/questions/63950633/android-11-capture-image-using-camera) – Syed Rafaqat Hussain Oct 25 '22 at 09:55

1 Answers1

0

Since API level 30 (Android 11), there have been changes in the package visibility.

For your package manager to work properly, you need to declare <queries> in your Androidmanifest.xml file

Code.

<manifest package="your.package.name">
<queries>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
</queries>
</manifest>

This will only be worked for android default camera apps

Happy Coding :)

Syed Rafaqat Hussain
  • 1,009
  • 1
  • 9
  • 33