storage-samples icon indicating copy to clipboard operation
storage-samples copied to clipboard

MediaStore sample load photos failed (most blank images)

Open skquo opened this issue 4 years ago • 2 comments

I tested the MediaStore sample on the Redmi Note 9 device, Android Q. Only several photos are loaded, other leave as blank.

Screenshot_2021-04-30-12-22-50-664_com android samples mediastore

It only works normal with requestLegacyExternalStorage.

skquo avatar Apr 30 '21 05:04 skquo

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
                }

               ...............................
               ........................
            }

`

anik-kucse avatar Jun 13 '21 11:06 anik-kucse

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?

renzified avatar Feb 25 '22 13:02 renzified