When you use movie to play an GIF picture, you can normally import a GIF file in assets, such as:
The code is as follows |
Copy Code |
Is=context.getresources (). Openrawresource (R.drawable.mygif); Movie = Movie.decodestream (IS); |
However, when the network picture is loaded locally, the following error is reported:
The code is as follows |
Copy Code |
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) |
I declared the permission in Androidmanifest.xml:
The code is as follows |
Copy Code |
<uses-permission android:name= "Android.permission.INTERNET"/> <uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> |
Solution:
code is as follows |
copy code |
InputStream is = null; try { is = new Bufferedinputstream (new FileInputStream (New File (Getcachedir (), "Mygif.gif")), 16 * 1024); Is.mark (16 * 1024); } catch (FileNotFoundException e) { //TODO Auto-generated Catch block e.printstacktrace (); } Movie = Movie.decodestream (is); |