在Android上:我怎样才能重新扫描整个文件夹来监视变化.nomedia [英] On Android: How can I rescan an entire folder to watch for changes in .nomedia
问题描述
所以,我的应用程序下载的用户从在线源要求的图像。通过在活动的一个按钮,用户可以选择隐藏或显示在画廊中的图像。这是很容易的,我只是根据需要添加或删除.nomedia文件。不过,我想每一次这样的变化是即时的,无需进一步的用户交互重新扫描介质。
So my app downloads images at the users' request from an online source. Through a button in the activity, the user can choose to hide or show the images in the gallery. This is easy enough, I just add or remove a .nomedia file as needed. However, I want to rescan media every time so that the change is instant, and requires no further user interaction.
之后,我使用的方法在 http://www.mail-archive.com/android-developers@googlegroups.com/msg24164.html 扫描特定的图像到库中。对于一个图像的伟大工程,但是当.nomedia文件被添加,我真正需要的是能够扫描整个目录。
After each image is downloaded, I am using the method at http://www.mail-archive.com/android-developers@googlegroups.com/msg24164.html to scan the specific image into the library. That works great for one image, but when the .nomedia file is added, I really need to be able to scan a whole directory.
我已经考虑调用MediaScannerNotifier目录中的每个图像上,但似乎只是笨拙和懒惰。
I have considered calling the MediaScannerNotifier on each image in the directory, but that just seems clumsy and lazy.
建议?
推荐答案
终于找到了在<一个href="http://groups.google.com/group/android-developers/browse_thread/thread/c1a385226f3df482">http://groups.google.com/group/android-developers/browse_thread/thread/c1a385226f3df482.
这是一个班轮:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse
("file://"
+ Environment.getExternalStorageDirectory())));
这篇关于在Android上:我怎样才能重新扫描整个文件夹来监视变化.nomedia的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!