Member-only story
Jetpack Compose New Photo Picker

What is Coil?
Coil is an open-source image-loading library for Android apps. It simplifies the process of loading images from the internet or local storage into your Android app and provides features such as caching, transformations, and error handling.
Setup
Add the dependency in :app/build.gradle
.
What is a URI?
As its name suggests, URI (Uniform resource identifier) is used to identify resources (whether it be a page of text, a video or sound clip, a still or image, or a program). In order to get the image URI we need to use the rememberLauncherForActivityResult()
, which allows you to get a result from an activity in your composable. In our example, we’re using it to open the photo picker.
What is the PickVisualMediaRequest?
PickVisualMediaRequest
is used to launch a system activity for picking visual media such as images or videos.
What is the AsyncImage?
AsyncImage
loads an image asynchronously from a URL or local storage and displays it.
Pick one photo
Firstly, we’ll have to create a variable that will hold the image URI, and then we’re creating a contract
that will open the image gallery. The PickVisualMedia
contract let the user pick only one photo from the gallery, and when the user picks a photo the value of selectedImageUri
gets updated.