I have an application that allows choosing image that will be further processed using the Storage Access Framework. I want to allow the user to preview the image in another application that is installed on the system.
Simplified example (where I only receive the file and re-open it immediatelly):
val documentId = /* get from the SAF */
val uri = DocumentsContract.buildDocumentUri(null, documentId)
// uri == "content:/..."
startActivity(Intent(Intent.ACTION_VIEW, uri).apply {
type = "image/jpeg", // TODO read from the SAF-received file
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
})
However, the image is not opened by the gallery application – only the gallery main screen is shown. I think I need to grant permission to the receiving app somehow.
I want to not assume that the user has installed gallery app with some specific app ID. I want to show a chooser to the user when multiple apps can open the image.