包装“隐藏”资产文件
我将文件“.nomedia”放入一个文件夹中,以避免 Android 的 MediaScanner 检测到该文件夹中的媒体文件。我需要将此文件夹(包括“.nomedia”)从 APK 的资产复制到 SD 卡(以便其他应用程序可以使用这些媒体文件等)。当我在 Eclipse 中打包 APK 时,它不会打包“.nomedia”文件。据推测,它会将其检测为隐藏文件。有什么想法如何解决这个问题吗?有我可以使用的秘密 aapt 标志吗?如果可能的话,我想避免复制文件夹然后手动创建“.nomedia”文件夹。
I'm placing the file '.nomedia' into a folder in order to avoid Android's MediaScanner from detecting the media files in the folder. I need to copy this folder (including '.nomedia') from the APK's assets to the SD card (so other apps can make use of these media files, etc.). When I package the APK in Eclipse, it doesn't package the '.nomedia' file. Presumably it's detecting it as a hidden file. Any ideas how to fix this? Is there a secret aapt flag I can use? I'd like to avoid copying the folder and then manually creating a '.nomedia' folder, if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是问题提出的几年后,但我自己在寻找同样的问题时遇到了这个问题,并发现了对我有用的解决方案,所以我想我会发布它:
在你的“ant.properties”文件中您的项目(如果没有,请创建一个新项目)添加这两行:
这将从默认排除列表中删除“.*”,因此 .nomedia 现在将包含在 .APK 内的资产目录中。
I know this is several years after the question was asked, but I ran into this question searching for the same issue myself, and discovered the solution that worked for me so I thought I would post it:
In your "ant.properties" file for your project (create a new one if you don't have it) add these two lines:
This will remove the ".*" from the default exclude list, and thus .nomedia will now be included in your assets directory inside your .APK.
资产被编译到应用程序中,您无法通过文件浏览器看到它们。您必须通过代码访问此文件夹,然后在首次启动或安装应用程序时将其复制到文件系统。看一下这个示例,它讨论了一个数据库文件,但一般来说,您希望对放入资产中的任何文件执行相同的操作并希望移动到文件系统:
http://www.helloandroid.com/tutorials/how-have-default-database
Assets get compiled into the application, you can't see them through file browser. You'd have to access this folder from code and then copy it to the file system when the app is first launched or installed. Take a look at this example, it talks about a database file, but in general you want to do the same thing for ANY file you put in assets and want to move to the file system:
http://www.helloandroid.com/tutorials/how-have-default-database