I'm working on an native android application in Java. I have already implemented camera functionalities that upload images to firebase storage when captured, but I expected that you could also open your gallery from the camera and upload those images like facebook messenger. Until now I have only found tutorials that separate camera and gallery with a menu that appears by clicking an add button.
Where gallery should normally be located in the camera application
Facebook messenger is implementing their own gallery, reading files probably from MediaStore.
If you want to open the gallery from your app and pick a picture you should launch an intent:
private val pickImageFromGallery = registerForActivityResult(ActivityResultContracts.GetContent()) {
uri: Uri? ->
uri?.let {
// handle the data here
}
}
Then launch the intent from a button click or something else:
pickImageFromGallery.launch("image/*")