无法使用免安装应用访问图库中的图像
Posted
技术标签:
【中文标题】无法使用免安装应用访问图库中的图像【英文标题】:Not able to access an image from the gallery with an instant app 【发布时间】:2021-07-14 15:12:33 【问题描述】:我有一个应用需要访问用户的图库才能选择图像并对其执行转换。我想将此功能移植到免安装应用体验中。我知道READ_EXTERNAL_STORAGE
权限不适用于即时应用,但ACTION_GET_CONTENT
或new ActivityResultContracts.GetContent()
我们不需要它。
我可以打开图库并选择一张图片,但是当我尝试访问它时出现此错误:
class j1.q: Failed to load resource
There were 3 causes:
java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 4): class j1.q: Fetching data failed, class java.io.InputStream, LOCAL
There was 1 cause:
java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: No content provider: content://com.android.providers.media.documents/document/image%3A221
Cause (2 of 4): class j1.q: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
There was 1 cause:
java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: No content provider: content://com.android.providers.media.documents/document/image%3A221
Cause (3 of 4): class j1.q: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL
There was 1 cause:
java.io.FileNotFoundException(No content provider: content://com.android.providers.media.documents/document/image%3A221)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: No content provider: content://com.android.providers.media.documents/document/image%3A221
Cause (4 of 4): class j1.q: Failed LoadPathHierarchicalUri->Bitmap->Bitmap, LOCAL
Cause (1 of 1): class j1.q: Failed DecodePathHierarchicalUri->Bitmap->Bitmap
我在 4 年前就看到过这个问题 Not able to launch Gallery from Android Instant app
现在我们可以打开图库了,所以也许谷歌方面对这个主题做了一些更改。
有人可以在免安装应用上从图库中获取图片吗?
【问题讨论】:
【参考方案1】:READ/WRITE_EXTERNAL_STORAGE:即时应用无法访问外部存储。 https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle#non-supported-permissions
【讨论】:
以上是关于无法使用免安装应用访问图库中的图像的主要内容,如果未能解决你的问题,请参考以下文章