Reputation: 1729
My question is regarding this post
Is it possible to set an animated gif file as live wallpaper in android?
The method given in this post does not seem to work. When i put my animated .gif file in /res/raw folder, there is an error which says that my file cannot be resolved or is not a field. Is there something that i should know about the resources in raw folder or there is some other problem. Following is the code.
BelleEngine() throws IOException {
InputStream is = getResources().openRawResource(R.raw.ballerina);
if (is != null) {
try {
mBelle = Movie.decodeStream(is);
mBelleDuration = mBelle.duration();
} finally {
is.close();
}
} else {
throw new IOException("Unable to open R.raw.belle");
}
Thanks for the help in advance!
Upvotes: 1
Views: 1599
Reputation: 2136
I have tried the example it works for me. Also i have tried this with different .gif images and it doesn't seems that their is any problem. My code for that is . {
/**
* Method to init suitable wallpaper according to time.
*/
private void initWallpaperAccordingtoTime(InputStream inputStream) {
if (inputStream != null) {
try {
wallpaperGifStream = Movie.decodeStream(inputStream);
if (wallpaperGifStream != null) {
duration = wallpaperGifStream.duration();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Call to this method will be as follows.
initWallpaperAccordingtoTime(getResources().openRawResource(
R.raw.android_apple));
}
Upvotes: 0