Xi 张熹
Xi 张熹

Reputation: 11071

Android share sheet does not display video preview

My app captures a video and saves it to disk using MediaStore. Then, it shares the video using the Android's default share sheet. The code is as following:

private fun shareMediaItem(uri: Uri) {
    try {
        val shareIntent = Intent().apply {
            action = Intent.ACTION_SEND
            putExtra(Intent.EXTRA_STREAM, uri)
            putExtra(Intent.EXTRA_TITLE, "Share screen recording")
            type = "video/mp4"
            addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
            intent.clipData = ClipData(null, arrayOf("video/mp4"), ClipData.Item(uri))
        }
        startActivity(Intent.createChooser(shareIntent, null))
    } catch (e: Exception) {
        Log.e("ShareMediaActivity", "Error sharing media item", e)
    }
}

I expect the share sheet to show the title and a preview of the video, but it only displays an app icon. If I try to share the video using Google Photo though, it displays a preview. Is there a way to make it display the video preview?

enter image description here

Upvotes: 0

Views: 92

Answers (2)

how8570
how8570

Reputation: 23

my reputation < 50 so place as Answer instate of comment back here

I'm pretty sure that video preview is provide by google photos MediaContentProvider and show on system Android sheet app (com.android.intentresolver, you can check it with adb or some reverse tools).

I guess there some hidden API maybe that we cannot use it, but I not found it yet (´;ω;`)

Upvotes: 0

Kolyneh
Kolyneh

Reputation: 444

I think the answer is no. I didn't find a way to show the video preview. What you see in Google Photo share ui is just an activity with custom layout, they make it looks like the system's share sheet.

Upvotes: 0

Related Questions