3

I am using a custom gallery to select the images but crashed in android 11 and i found due to scoped storage

1 Answers1

0

Use the following code

in Manifest file

 <!--Android 11 camera query-->
<queries>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
</queries>

<queries>
    <intent>
        <action android:name="android.intent.action.PICK" />
    </intent>
</queries>

Activity

        Intent(Intent.ACTION_GET_CONTENT).also { intent ->
        intent.type = "image/*"
        intent.resolveActivity(requireActivity().packageManager)?.also {
            intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
            startActivityForResult(intent, REQUEST_PICK_IMAGE)
        }
    }
Yahya M
  • 392
  • 3
  • 13