Android 13 Photo / Video Picker - file name from the URI is garbage
12:38 24 Apr 2023

When using the picker introduced with Android 13 via ActivityResultContracts.PickVisualMedia a Uri is returned (representing the selected media item):

content://media/picker/0/com.android.providers.media.photopicker/media/1000000198

If I use the content resolver and interrogate the cursor I get something like:

duration = 38003
orientation = 0
height = 2336
_display_name = 1000000198.mp4
datetaken = 1681826421000
mime_type = video/mp4
_data = /sdcard/.transforms/synthetic/picker/0/com.android.providers.media.photopicker/media/1000000198.mp4
_size = 9920806
width = 1072

The column usually used for the filename is OpenableColumns.DISPLAY_NAME (_display_name). However as you can tell the values here are just some garbage number filename and not the actual filename that was selected. This is NOT the actual filename of the selected video.

Is there any way to use this Android 13 photo/video picker and get the actual filename of the file the user selected and not this garbage number filename?

android