What permissions and for what API versions are required to request a photo/video from the gallery using PhotoPicker with
registerForActivityResult(
ActivityResultContracts.PickMultipleVisualMedia())
?
The application supports Android 8 (API 26). If I understand correctly, Android 14 does not require permissions? But in other versions? I did not find any clear explanations about this in the documentation.
Yes, starting with Android 14 (API level 34), media selection (images, videos, etc.) no longer requires any permissions, as Android 14 has significantly streamlined access to media files.
Key Points for Media Access in Android 14 (API level 34):
-
No permissions required for media access:
- Users can access media files (images, videos, etc.) without needing to request specific permissions such as
READ_MEDIA_IMAGES
,READ_MEDIA_VIDEO
, orREAD_MEDIA_AUDIO
.
- Users can access media files (images, videos, etc.) without needing to request specific permissions such as
-
PhotoPicker API:
- Available natively for single media selection and no permissions are required.
-
PickMultipleVisualMedia API:
- Also available for multiple media selection, and again, no permissions are required for accessing media.
-
Scoped Storage is enforced:
- Even though no explicit permissions are required, the scoped storage model still applies, meaning apps are limited to accessing only the media that the user selects, either via PhotoPicker or PickMultipleVisualMedia, and not the entire storage.
-
Android 9 (API 28) and Below:
- Permissions:
READ_EXTERNAL_STORAGE
,WRITE_EXTERNAL_STORAGE
. - Key Notes: Full external storage access without restrictions. No Scoped Storage model, meaning apps can access all files without limitations.
- Permissions:
-
Android 10 (API 29):
- Permissions:
READ_EXTERNAL_STORAGE
, Scoped Storage. - Key Notes: Scoped Storage introduced. Apps are restricted to access only their own private storage or shared media (via
MediaStore
). No PhotoPicker API.
- Permissions:
-
Android 11 (API 30):
- Permissions:
READ_MEDIA_IMAGES
,READ_MEDIA_VIDEO
,READ_MEDIA_AUDIO
. - Key Notes: Scoped Storage enforced with granular permissions for different types of media. The PhotoPicker API is introduced, allowing users to select images and videos more easily. Apps need to request specific media permissions for images, videos, and audio.
- Permissions:
-
Android 12 (API 31):
- Permissions:
READ_MEDIA_IMAGES
,READ_MEDIA_VIDEO
,READ_MEDIA_AUDIO
. - Key Notes: Granular media permissions continue. Scoped Storage is fully enforced, restricting file access further. Apps must request specific permissions for media access (e.g., images, videos). The PhotoPicker API remains available.
- Permissions:
-
Android 13 (API 33):
- Permissions:
READ_MEDIA_IMAGES
,READ_MEDIA_VIDEO
,READ_MEDIA_AUDIO
. - Key Notes: Granular permissions remain in place. The PickMultipleVisualMedia API is introduced, allowing users to select multiple images or videos at once.
- Permissions:
-
Android 14 (API 34):
- Permissions: No permissions required for media access.
- Key Notes: No permissions are needed for accessing media like images, videos, or audio. The PhotoPicker API continues with improvements to allow easier media selection. Further optimizations and user privacy features added.
These key notes outline the evolution of Scoped Storage, permissions for accessing media, and the introduction of PhotoPicker and PickMultipleVisualMedia across different Android versions.
And,
Key Points for PhotoPicker API and PickMultipleVisualMedia API Availability:
1. Android 13 (API level 33) and above:
- PickMultipleVisualMedia API is natively available:
- Allows users to select multiple images or videos in a single picker interface.
- The first native API to support multiple media selection directly.
- Available alongside the PhotoPicker API.
- PhotoPicker API is natively available:
- Allows users to select single images or videos.
- Introduces granular permissions for media access (
READ_MEDIA_IMAGES
,READ_MEDIA_VIDEO
,READ_MEDIA_AUDIO
).
2. Android 12 (API level 31):
- PickMultipleVisualMedia API is not available:
- Android 12 supports only single media selection via the PhotoPicker API (for selecting one image or video at a time).
- PhotoPicker API is natively available:
- Allows single media selection.
- Granular media permissions introduced for more control over which types of media are accessible.
3. Android 11 (API level 30):
- PickMultipleVisualMedia API is not available:
- Only the PhotoPicker API is available for single media selection.
- PhotoPicker API is natively available:
- Allows single media selection.
- Introduces granular permissions for images, videos, and audio.
4. Android 10 (API level 29) and below:
- Neither the PickMultipleVisualMedia API nor the PhotoPicker API is natively available:
- You can use Storage Access Framework (SAF) or MediaStore API for file access.
- Multi-selection is not natively supported, and a custom solution must be implemented for selecting multiple media items.
5. Backporting for Android 4.4 to 10 (API 19-29) and Android Go Devices (with Android 11/12):
- PhotoPicker API can be backported via Google Play services for single media selection on devices running Android 4.4 to Android 10 and Android Go devices running Android 11/12.
- This backporting is achieved by adding a metadata entry in the app’s manifest file.
- Only single media selection is possible when using the backported PhotoPicker API.
- The PickMultipleVisualMedia API cannot be backported to versions below Android 13 (API 33).