IceFox_Programming
IceFox_Programming

Reputation: 125

Can you open gallery when camera app is open to get images in android studio?

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

Upvotes: 1

Views: 928

Answers (1)

Nestor Perez
Nestor Perez

Reputation: 887

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/*")

Upvotes: 0

Related Questions