0

I want to create an Android Gallery/Photos viewer that lets the user PICK a profile picture. Based on all the examples I looked at, this is my code for doing so.

    val galleryIntent = Intent(Intent.ACTION_GET_CONTENT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
    galleryIntent.type = "image/*"
    galleryIntentLauncher.launch(galleryIntent)

Unfortunately this opens to the root of some file system, but I want it to open directly to the Gallery or Google Photos or whatever is the correct location for the photo gallery on the device.

I realize this varies by manufacturer (OnePlus, Samsung, Google, etc.) and that may be the reason what I want to do is impossible, but I know I've seen other apps do it.

Is there some formal/common way of doing this (i.e. opening directly to the photo gallery instead of the root directory)?

Bungles
  • 1,969
  • 2
  • 25
  • 54
  • 2
    `Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)` Try creating your intent like this. – Vikas Choudhary Nov 13 '21 at 19:00
  • I tried that. PICK behaves exactly the same as GET_CONTENT. – Bungles Nov 13 '21 at 19:24
  • There is no 'the foto gallery' on an Android device. There may be installed some 'gallery' apps that show pictures and other media. There is nothing in Android that would start a 'gallery' app. But if you know package name of an app you can create a launch intent for it. – blackapps Nov 13 '21 at 20:30
  • So how do other apps like Facebook open directly into the Google Photos directory? – Bungles Nov 13 '21 at 22:09
  • @Bungles what about this? when I use it, it offers me my gallery or google photos val galleryIntent = Intent.ACTION_PICK galleryIntent.type = "image/*" galleryIntentLauncher.launch(galleryIntent) – Yura Nov 14 '21 at 01:18

0 Answers0