How to put a wallpaper inside an apk file?

浪尽此生 提交于 2019-12-10 12:01:03

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/3717752/how-to-put-a-wallpaper-inside-an-apk-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!