I am using a custom gallery to select the images but crashed in android 11 and i found due to scoped storage
Asked
Active
Viewed 753 times
3
-
add more details show your logcat so we can check – Usama Altaf Dec 16 '20 at 09:12
-
1You'll have to describe what you tried, what happens specifically, and any relevant piece of code. Additionally, you might find this tutorial useful: https://www.raywenderlich.com/10768834-scoped-storage-tutorial-for-android-11-deep-dive – Miguel Lasa Feb 03 '21 at 14:54
-
Read this: https://stackoverflow.com/a/66366102/9917404 – Thoriya Prahalad Feb 25 '21 at 09:55
1 Answers
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