How to Use Photo Picker in Android 13?
Last Updated :
24 Apr, 2025
With Android 13, Google unveiled a new specialized media picker. This new option provides a more private and user-friendly alternative for those times when you want to share photographs, as opposed to potentially granting apps access to all of your files via the well-known document picker. You don't actually need Android 13 on your phone to use this media picker because Google was able to integrate it into the Google Play Services. In fact, Google just announced that it had backported the functionality all the way back to Android 4.4 KitKat, which was initially introduced in 2013. The photo picker offers a browse-and-search interface that shows the user their media library, arranged by date (newest to oldest) and searchable. The photo picker offers a secure, built-in solution for users to provide your app access to just the selected photos and videos instead of their whole media collection
This implies that developers may incorporate the media picker into their programs considerably more quickly than they would typically. The media picker is a standard component of any phone that uses Play Services, so developers won't have to wait for the majority of Android phones to be updated to a version that supports this functionality. Without requiring any code modifications, the tool updates automatically, providing users of your app with more capabilities over time. Devices that fit the following description can use the photo picker:
- Run Android 11 (API level 30) or a later version.
- Google System Updates provides updates for Modular System Components.
How to Implement the new Android 13 Image Picker in the Android Application?
Even if it sounds hard in the first place to get the cool new image picker quickly in Android Deployment, it's actually very easy, we will be using Jetpack to get our work done, just follow the below steps in order to get the thing up and running in no time! But, before jumping in, there are two types of intent we can use to choose our images, they are:
- PickVisualMedia to pick a single still or moving image.
- PickMultipleVisualMedia to choose a number of pictures or movies.
Step #1: If you need to upload only single files
If you wish to allow the user to only select a single file, then you can use the code below to achieve the same.
Java
ActivityResultLauncher<PickVisualMediaRequest>
gfgMediaPicker = registerForActivityResult(
new PickVisualMedia(), uri -> {
if (uri != null) {
Log.d("PhotoPicker",
"Selected URI: " + uri);
}
else {
Log.d("Opened the picker",
"Select something geek");
}
});
gfgMediaPicker.launch(
new PickVisualMediaRequest.Builder()
.setMediaType(
PickVisualMedia.ImageAndVideo.INSTANCE)
.build());
gfgMediaPicker.launch(
new PickVisualMediaRequest.Builder()
.setMediaType(PickVisualMedia.ImageOnly.INSTANCE)
.build());
.gfgMediaPicker.launch(
new PickVisualMediaRequest.Builder()
.setMediaType(PickVisualMedia.VideoOnly.INSTANCE)
.build());
String mimeType = "image/gif";
gfgMediaPicker.launch(
new PickVisualMediaRequest.Builder()
.setMediaType(
new PickVisualMedia.SingleMimeType(mimeType))
.build());
Step #2: If you need to upload multiple images
Sometimes, you may require the user to upload multiple files, if like for example, if you have a social media application, where the user can post multiple images, the process to select multiple images are as follows:
Java
ActivityResultLauncher<PickVisualMediaRequest>
pickMultipleMedia = registerForActivityResult(
new PickMultipleVisualMedia(5), gfgPhotoPicker -> {
if (!gfgPhotoPicker.isEmpty()) {
Log.d("PhotoPicker",
"Number of items selected: "
+ gfgPhotoPicker.size());
}
else {
Log.d("Opened Picker",
"Choose something Geek");
}
});
pickMultipleMedia.launch(
new PickVisualMediaRequest.Builder()
.setMediaType(
PickVisualMedia.ImageAndVideo.INSTANCE)
.build());
What if the app needs background access to photos?
If your app is a photo uploading application, or perhaps a photo back-up application, then you might need to require continuous access to the photos, even after the device has been rebooted. To do this, we will simply take the takePersistableUriPermission.
Java
int gfgFlagger = Intent.FLAG_GRANT_READ_URI_PERMISSION;
context.contentResolver.takePersistableUriPermission(uri, flag);
Conclusion
That's it, you have completed adding the newest photo-picker to your Android Application, and can now leverage it to allow your users an even smoother experience. The new pop-up is user-friendly and is also baked from keeping privacy in mind from the start, hope you use this to great use.
Similar Reads
How to Use Phone Selector API in Android?
Phone Selector API is used to detect phone numbers being used in the phone. Using this you can avoid manual input of Phone Numbers by users and prompt them to choose the desired number. A sample image is given below to get an idea about what we are going to do in this article. Note that we are going
3 min read
Photo Picker in Android 13 with Example Project
In many android applications, we get to see that they are picking images from the user's device and displaying that images within the android application. For image picking, android applications use intent within the android application. In this article, we will take a look at How to implement Photo
3 min read
How to Use Quick Settings Placement API in Android 13?
Quick Settings tile is a quick setting that is present in the android device notification bar from where we can easily enable and disable the device or app settings such as Bluetooth or wifi. In this article, we will take a look at How to add a Quick Tile to our android device using Quick Settings P
3 min read
How to Implement PDF Picker in Android?
In this article, we are going to see how we can implement a PDF picker in android studio and get the file information of the pdf like file name, size and path. In this application, we will create a launcher to launch the file picker and display the file information after a pdf is picked successfully
5 min read
How to Use Magnifier API in Android?
You may have encountered a magnified effect when you have scrolled over text view in recent versions of Android, and have wanted to integrate the same functionality in your app as well. In this article, we will learn how to work towards implementing the same in your app. The magnifier widget, which
4 min read
Time Picker Dialog in Android
Android TimePicker is a user interface control for selecting the time in either 24-hour format or AM/PM mode. It is used to ensure that users pick the valid time for the day in our application. The time picker interface exists basically in two modes one is under XML layout and another is a dialog. I
3 min read
How to Take Sub-View Screenshot in Android?
A Sub-view in Android can be any UI element present on the screen that has a parent layout or a parent view. It is simply a view inside a view. Assuming, we create a TextView in our activity. As this TextView is present inside the main layout, it is a sub-view of the main layout. Similarly, other el
4 min read
How to Capture HDR Videos in Android 13?
You can preview and capture HDR video material with your camera thanks to the Camera2 APIs' support for high dynamic range (HDR) video capture. The video which is taken in HDR is way ahead of the Standard Video that your current app is currently rendering, and is a must to use if the user's device s
4 min read
How to Use PRDownloader Library in Android App?
PRDownloader library is a file downloader library for android. It comes with pause and resumes support while downloading a file. This library is capable of downloading large files from the internet and can download any type of file like image, video, pdf, apk and etc. It provides many features that
11 min read
Slider Date Picker in Android
Slider Date Picker is one of the most popular features that we see in most apps. We can get to see this Slider date picker in most of the travel planning applications, Ticket booking services, and many more. Using Slider date Picker makes it efficient to pick the date. In this article, we are going
3 min read