I've been dealing with a nasty bug in Helium (formerly Carbon) since the initial release: The app icons that are saved to the SD Card during app backup pollute the user's Gallery. I tore my hair out trying to fix this, as this was the number one complaint about the app, including:
Then the obvious solution hit me: look at the Android source code and see how the MediaScanner works, and figure out how to bypass it.
Digging through MediaScanner.java, I found that any file designated as "isNoMediaFile" would not be scanned. But, I didn't want to name the image.png files, .nomedia, as that is just hacky. Looking through the implementation of isNoMedia, I found that not just .nomedia files fall into this category...
Well, apparently '._' prefixed files are also considered "isNoMediaFile"! This is there because mounting the external SD card on a Mac often results in the Mac creating '._' files in various directories. This is the Mac convention for hidden system files, and Android needs to ignore those files as well!
So, the fix was to change "file.png" to "._file.png". Though, one should also keep a .nomedia file anyways, as this is the recommended practice, and it also ensures backwards compatibility with older versions of Android.
Although I consider it a bug that the MediaScanner is scanning directories with .nomedia files in them, I am relieved and happy to find a workaround.