Android的 - .nomedia不工作的图片 [英] Android - .nomedia not working for images
问题描述
我的图像,从SD卡只能通过特定的应用程序,所以我想从图片库隐藏它读取的。我已经把.nomedia文件,但这个文件将被忽略,图像仍显示在画廊。我已经把它。在一开始的时候。仍然没有工作。任何想法?
I have images, which are read from sdcard only by particular application so I want to hide it from image gallery. I have put .nomedia file in it, but this file is ignored, images are still showing in Gallery. I have put it with "." in the beginning. Still not working. Any ideas?
推荐答案
我猜你使用的是Android 4.0,为 .nomedia
正常运作到那时。在AOSP 错误报告的问题说明:
I'm guessing you're using Android 4.0, as .nomedia
functioned properly until then. The AOSP bug report for the issue explains:
MediaScanner
在Android 4.0不能忘记已经建立索引的文件,它遇到一个 .nomedia
文件时,却并兑现它,如果它是在第一轮present。因此,解决方法是简单地重命名的目录。当然,你可以在下一次扫描后,将名称更改回来,如果你喜欢。
MediaScanner
on Android 4.0 fails to forget already-indexed files when it encounters a .nomedia
file, but it does honor it if it's present on the first pass. So the workaround is to simply rename the directory. Of course you can change the name back after the next scan, if you like.
更新的:我想彻底的解决办法是重命名目录后,竟强制媒体扫描。我还没有尝试过,但这样的事情应该做的伎俩:
Update: I suppose the complete solution would be to actually force a media scan after renaming the directory. I haven't tried it, but something like this should do the trick:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" +
Environment.getExternalStorageDirectory())));
这篇关于Android的 - .nomedia不工作的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!