Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaStore sample load photos failed (most blank images) #96

Open
skquo opened this issue Apr 30, 2021 · 2 comments
Open

MediaStore sample load photos failed (most blank images) #96

skquo opened this issue Apr 30, 2021 · 2 comments

Comments

@skquo
Copy link

skquo commented Apr 30, 2021

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.

@anik-kucse
Copy link

anik-kucse commented Jun 13, 2021

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
                }

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

`

@basurahan
Copy link

basurahan commented Feb 25, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@anik-kucse @basurahan @skquo and others