I have an app that shows GIF images. It all works fine if image is saved in drawable, and I access it like this
is=context.getResources().openRawResource(R.drawable.mygif);
movie = Movie.decodeStream(is);
But I need to download image from internet, so I'm saving it to CacheDir, that works fine. I tried the following to read it.
try
{
is = new BufferedInputStream(new FileInputStream(new File(context.getCacheDir(), "mygif.gif")));
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
movie = Movie.decodeStream(is);
And this
movie = Movie.decodeFile(new File(context.getCacheDir(), "mygif.gif").getPath());
But no matter what, it ends with
java.io.IOException
at java.io.InputStream.reset(InputStream.java:218)
at android.graphics.Movie.decodeStream(Native Method)
at android.graphics.Movie.decodeTempStream(Movie.java:74)
at android.graphics.Movie.decodeFile(Movie.java:59)
or
java.io.IOException: Mark has been invalidated.
at java.io.BufferedInputStream.reset(BufferedInputStream.java:350)
at android.graphics.Movie.decodeStream(Native Method)
I think it's a very simple error, but I can't get over it. Manifest has:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>