如何在 apk 文件中放置壁纸? [英] How to put a wallpaper inside an apk file?
问题描述
我打算发布一个漂亮的时钟小部件,我想在其中包含一个漂亮的墙纸(想这样做是因为之前收到了一些评论,例如我可以得到匹配的墙纸吗?;)")
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? ;)")
所以我尝试用谷歌搜索如何将一些图像文件放入 apk 中,以便它在安装后出现在壁纸选择列表中.我的意思是在执行 Home=>Menu=>Wallpaper=>Wallpaper Gallery 或 Pictures 时出现的列表 - 随便.
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?
推荐答案
你可以将壁纸打包在 res/raw 中,然后当你的应用第一次启动时,尝试将其复制到 sdcard 目录/media/图片.
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.
您应该使用诸如 getExternalStorageDirectory 或 getExternalStoragePublicDirectory(取决于 API 级别)之类的方法来打开文件.
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
这篇关于如何在 apk 文件中放置壁纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!