包装“隐藏”资产文件

发布于 2024-09-05 03:18:44 字数 260 浏览 2 评论 0原文

我将文件“.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风筝有风,海豚有海 2024-09-12 03:18:44

我知道这是问题提出的几年后,但我自己在寻找同样的问题时遇到了这个问题,并发现了对我有用的解决方案,所以我想我会发布它:

在你的“ant.properties”文件中您的项目(如果没有,请创建一个新项目)添加这两行:

# DO NOT ignore the .nomedia file in the assets directory!
aapt.ignore.assets="!.svn:!.git:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"

这将从默认排除列表中删除“.*”,因此 .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:

# DO NOT ignore the .nomedia file in the assets directory!
aapt.ignore.assets="!.svn:!.git:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"

This will remove the ".*" from the default exclude list, and thus .nomedia will now be included in your assets directory inside your .APK.

故人的歌 2024-09-12 03:18:44

资产被编译到应用程序中,您无法通过文件浏览器看到它们。您必须通过代码访问此文件夹,然后在首次启动或安装应用程序时将其复制到文件系统。看一下这个示例,它讨论了一个数据库文件,但一般来说,您希望对放入资产中的任何文件执行相同的操作并希望移动到文件系统:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文