如何将壁纸放入 apk 文件中?
我计划发布一个漂亮的时钟小部件,并且我想在其中包含一个漂亮的壁纸(想要这样做,因为之前收到了一些评论,例如“我可以获得匹配的壁纸吗?;)”)
所以我尝试谷歌关于如何将一些图像文件放入 apk 中,以便安装后它会出现在壁纸选择列表中。我的意思是在执行“主页=>菜单=>壁纸=>壁纸库”或“图片”时出现的列表 - 无论如何。
目前还没有找到任何提示,所以决定尝试在这里询问。
关于如何做到这一点有任何提示吗?
I'm planning to release a nice clock widget and I'd like to include a pretty wallpaper with it (want to do this because previously got some comments like "can i get the matching wallpaper? ;)")
So I tried to google on how to put some image file inside apk so that it would appear in wallpapers selection list after installation. I mean the list which appears when doing Home=>Menu=>Wallpaper=>Wallpaper Gallery or Pictures - whatever.
So far didn't find any hints, so decided to try to ask here.
Any hints on how to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将壁纸打包在 res/raw 中,然后当您的应用程序第一次启动时,尝试将其复制到 sdcard 目录 /media/pictures。
您应该使用 getExternalStorageDirectory 或 getExternalStoragePublicDirectory 等方法(取决于 API 级别)来打开文件。
http://developer.android.com/guide/topics/数据/data-storage.html#filesExternal
You could package the wallpaper in res/raw, and then when your app fires up for the first time, attempt to copy it to the sdcard directory /media/pictures.
You should be using methods such as getExternalStorageDirectory or getExternalStoragePublicDirectory (depending on the API level) to open the file.
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal