Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
Created May 1, 2020 23:50
Show Gist options
  • Save wajahatkarim3/c7a71093924384bc1ed3d2e608a62d41 to your computer and use it in GitHub Desktop.
Save wajahatkarim3/c7a71093924384bc1ed3d2e608a62d41 to your computer and use it in GitHub Desktop.
// Pick Images Contract - Normally this is for all kind of files.
private val pickImages = registerForActivityResult(ActivityResultContracts.GetContent()) {uri ->
uri?.let {uri ->
imageView.setImageURI(uri)
}
}
// Calling GetContent contract
pickImageButton.setOnClickListener {
pickImages("image/*") // We want images, so we set the mimeType as "image/*"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment