On this article, we are going to find out about Android14’s new permissions enable customers ARRIVE entry permissions ARRIVE chosen media solely (Picture🖼️/Video🎥)than than the total library.
This new rights enable person ARRIVE grant partial entry ARRIVE media
when our app is operating on Android14 or larger
After we declare READ_MEDIA_VISUAL_USER_SELECTED
this new rights and person selects Choose photographs and movies(Choose photographs or Choose movies)
:
- The
READ_MEDIA_IMAGES
AndREAD_MEDIA_VIDEO
proper is each refuse - The
READ_MEDIA_VISUAL_USER_SELECTED
permission is such an instance ✅, present partial and momentary entry arrive person photographs and movies(picture or video) - Later, if we’d like Entry further photographs and movieswe should handmade the request
READ_MEDIA_IMAGES
orREAD_MEDIA_VIDEO
permissions (or each).
-
Add the next permissions
AndroidManifest.xml
// new permisison
-
Request permission to make use of
ActivityResultContract
We have to request it with
READ_MEDIA_IMAGES
,READ_MEDIA_VIDEO
in order that’s why we useRequestMultiplePermissions
val permissionLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { mapResults ->
mapResults.forEach {
Log.d(TAG, "Permission: ${it.key} Standing: ${it.worth}")
}
// test if any of the requested permissions is granted or not
if (mapResults.values.any { it }) {
// question the content material resolver
queryContentResolver(context) { listOfImages ->
imageDataModelList = listOfImages
}
}
}