Open skquo opened 3 years ago
Check the size for each media object whether it is zero or not. I fixed my problem like that.
` val projection = arrayOf( MediaStore.Files.FileColumns.SIZE, ................................................ )
....................................................
....................................................
val fileSizeColumn = cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE)
while (cursor.moveToNext()) {
val fileSize = cursor.getLong(fileSizeColumn)
if (fileSize == 0L) {
continue
}
...............................
........................
}
`
Check the size for each media object whether it is zero or not. I fixed my problem like that.
` val projection = arrayOf( MediaStore.Files.FileColumns.SIZE, ................................................ )
.................................................... ....................................................
val fileSizeColumn = cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE)
while (cursor.moveToNext()) { val fileSize = cursor.getLong(fileSizeColumn) if (fileSize == 0L) { continue } ............................... ........................ }
`
Yes this will work on your own app but on the default gallery of the phone it will show those blank images. How can we fix that?
I tested the MediaStore sample on the Redmi Note 9 device, Android Q. Only several photos are loaded, other leave as blank.
It only works normal with requestLegacyExternalStorage.