小编Sou*_*wat的帖子

如何解决直接将图像从 Android 图库共享到我的 flutter 应用程序时收到的奇怪且不完整的 Uri 和路径

我在 Kotlin 中为 flutter 应用程序编写了一个功能,可以将媒体文件直接从 Android 手机图库共享到应用程序。

在我测试过的许多设备上运行良好,例如 Realme 3 Pro、Oneplus 6t、三星 m40。

但是,在Asus Zenfone Max Pro M2共享任何媒体文件时,都会收到奇怪且不完整的信息URI&path

来自 Kotlin 代码的日志

D/URI =====(26032) : content://com.android.providers.downloads.documents/document/624

D/路径 =====(26032): /document/624

Kotlin 代码

override fun onAttachedToActivity(binding: ActivityPluginBinding) {
    this.binding = binding
    binding.addOnNewIntentListener(this)
    handleIntent(binding.activity.intent, true)
}
----------------------------------------------------------------------
private fun handleIntent(intent: Intent, initial: Boolean) {
    when {
        (intent.type?.startsWith("text") != true)
                && (intent.action == Intent.ACTION_SEND
                || intent.action == Intent.ACTION_SEND_MULTIPLE) -> { // Sharing images or videos

            val value = getMediaUris(intent)
            if …
Run Code Online (Sandbox Code Playgroud)

android kotlin flutter asus flutter-android

14
推荐指数
1
解决办法
961
查看次数

标签 统计

android ×1

asus ×1

flutter ×1

flutter-android ×1

kotlin ×1