I have an application that displays GIF images. Everything works fine if the image is saved in drawable, and I refer to it as follows
is=context.getResources().openRawResource(R.drawable.mygif); movie = Movie.decodeStream(is);
But I need to download the image from the Internet, so I save it to CacheDir, this works fine. I tried to read this.
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 one
movie = Movie.decodeFile(new File(context.getCacheDir(), "mygif.gif").getPath());
But no matter what ends on
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 this is a very simple mistake, but I cannot overcome it. The manifest has:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
source share