我使用照片选择器来检索照片,然后我遵循 https://developer.android.com/training/data-storage/shared/photopicker。我们已经看到以下一些设备在 Android 11 及更高版本的设备中崩溃。
非致命异常:java.io.FileNotFoundException:没有这样的文件或目录 在 android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:156)
这个问题是因为没有添加 FLAG_GRANT_READ_URI_PERMISSION 吗?
我怀疑这个问题是因为缺少以下几行
val 标志 = Intent.FLAG_GRANT_READ_URI_PERMISSION context.contentResolver.takePersistableUriPermission(uri, 标志)