I was able to get the "Browse" option by using ActivityResultContracts.GetContent()
instead of ActivityResultContracts.PickVisualMedia()
. What this is effectively doing is creating the following Intent:
Intent(Intent.ACTION_GET_CONTENT)
.addCategory(Intent.CATEGORY_OPENABLE)
.setType("image/*")
I believe you can launch that intent directly or my code is using the ActivityResultContracts paradigm inside of a composable so it looks like this:
val photoPickerLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri ->
//do something with image uri
}
photoPickerLauncher.launch(MIME_TYPE_IMAGE)
Previously I was using ActivityResultContracts.PickVisualMedia()
as outlined in the docs. With that, I wasn't getting the browse option on the photo picker. With the code above, I do. I also tested on an Android 11 device and it works fine using the old gallery UI.
Now I can't really explain why this works so use at your own risk. I find documentation for PhotoPicker and Gallery selection in general very poor. But this seemed to work for me.