Вопрос

So, I know how to detect USB mass storage being connected and disconnected. So far so good.

But now I have a problem, wherein once I get out of USB mode in my app, MediaStore begins to scan media, I wait for that scanning to be complete, and then I try to access some content from MediaStore. I store the ID of images and videos and try to get the URI of those items once scanning is complete.

But now when I query for the URI of those files with the stored ID I have, some of the files' URIs come out as null. And that's my problem, because they shouldn't be.

Does anyone have pointers as to what I am missing?

Это было полезно?

Решение

after USB mode Switching, When a USER comes out of USB mode, Mediastore does the scanning and in process, it happens to enumerate the ID's differently than it did before. Not sure why, but i compared same image and it seemed to have different ID than it had before. Doesn't happen always but it may or may not. So i needed to wait for scan to finish and update the ID's i was storing. That seems to solve the issue

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top