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

Android: use MediaScannerConnection #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ath0mas
Copy link

@ath0mas ath0mas commented Aug 30, 2023

Similar to #2 but replace it.

Tested on emulators with various versions, like 24, 28, 29, 30, 33, and a real device api 27.
It gives really good results with MediaScannerConnection.scanFile for a file written to the app external media dir (<external>/Android/media/<app-id>).

While MediaStore insert was not working as expected for 30 to 33, not adding the media to the gallery, and instead creating an empty entry ; for api 29 and before, results were correct but not as consistent as expected.


The Intent ACTION_MEDIA_SCANNER_SCAN_FILE is deprecated and is not effective anymore.

See https://developer.android.com/reference/android/content/Intent#ACTION_MEDIA_SCANNER_SCAN_FILE

Callers should migrate to inserting items directly into MediaStore, where they will be automatically scanned after each mutation.


+ prevent continue after Invalid File Path error

ath0mas added a commit to ath0mas/cordova-plugin-gallery-refresh that referenced this pull request Sep 26, 2023
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

Successfully merging this pull request may close these issues.

None yet

1 participant