在android live壁纸中使用.gif文件
我的问题是关于这个帖子 这篇文章中给出的方法似乎不起作用。当我将动画.gif文件放在/res/raw文件夹中时,出现一个错误,表明我的文件无法解析或不是字段。关于原始文件夹中的资源,是否有我应该知道的内容,或者是否存在其他问题。下面是代码 BelleEngine抛出异常{在android live壁纸中使用.gif文件,android,live-wallpaper,animated-gif,Android,Live Wallpaper,Animated Gif,我的问题是关于这个帖子 这篇文章中给出的方法似乎不起作用。当我将动画.gif文件放在/res/raw文件夹中时,出现一个错误,表明我的文件无法解析或不是字段。关于原始文件夹中的资源,是否有我应该知道的内容,或者是否存在其他问题。下面是代码 BelleEngine抛出异常{ InputStream is = getResources().openRawResource(R.raw.ballerina); if (is != null) { t
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");
}
提前感谢您的帮助!我已经尝试了它对我有用的示例。我还尝试了不同的.gif图像,它们似乎没有任何问题。我的代码是。 { 对该方法的调用如下所示 }
/**
* 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();
}
}
}
}
initWallpaperAccordingtoTime(getResources().openRawResource(
R.raw.android_apple));