I was able to replace MediaStore.MediaColumns.Data with its own file ID (incredibly, files have IDs) and correctly constructing its URI, like this:fun getAllShownImagesPath(activity: Activity): MutableList<Uri> { val uriExternal: Uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI val cursor: Cursor? val columnIndexID: Int val listOfAllImages: MutableList<Uri> = mutableListOf() val projection = arrayOf(MediaStore.Images.Media._ID) var imageId: Long cursor = activity.contentResolver.query(uriExternal, projection, null, null, null) if (cursor != null) { columnIndexID = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID) while (cursor.moveToNext()) { imageId = cursor.getLong(columnIndexID) val uriImage = Uri.withAppendedPath(uriExternal, "" + imageId) listOfAllImages.add(uriImage) } cursor.close() } return listOfAllImages} ,然后使用Uri在视图中构建它! 这篇关于MediaStore.MediaColumns.DATA已过时,我想将图像从图库加载到我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 04:07