문제

I'm using below code. When executeing Movie.decodeFile(pathName) i got IOException.

Movie movie;
            File dir = Environment.getExternalStorageDirectory();  
            File file = new File(dir,"weather.gif");

            String pathName = file.getAbsolutePath();
            Log.d("rvg", "Path: "+pathName);
            if(file.exists())
            {
                Log.d("rvg", "image available");
                movie=Movie.decodeFile(pathName);
            }
            else
            {
                Log.d("rvg", "image not available");
            }

Logcat exception:

08-19 05:55:43.271: D/rvg(1458): Path: /mnt/sdcard/weather.gif
08-19 05:55:43.271: D/rvg(1458): image available
08-19 05:55:43.271: W/System.err(1458): java.io.IOException
08-19 05:55:43.271: W/System.err(1458):     at java.io.InputStream.reset(InputStream.java:218)
08-19 05:55:43.271: W/System.err(1458):     at android.graphics.Movie.decodeStream(Native Method)
08-19 05:55:43.271: W/System.err(1458):     at android.graphics.Movie.decodeTempStream(Movie.java:74)
08-19 05:55:43.271: W/System.err(1458):     at android.graphics.Movie.decodeFile(Movie.java:59)
08-19 05:55:43.271: W/System.err(1458):     at com.android.gif.GIFDemo$GIFView.<init>(GIFDemo.java:64)
08-19 05:55:43.271: W/System.err(1458):     at com.android.gif.GIFDemo$1.run(GIFDemo.java:36)
08-19 05:55:43.271: W/System.err(1458):     at android.os.Handler.handleCallback(Handler.java:615)
08-19 05:55:43.271: W/System.err(1458):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-19 05:55:43.271: W/System.err(1458):     at android.os.Looper.loop(Looper.java:137)
08-19 05:55:43.271: W/System.err(1458):     at android.app.ActivityThread.main(ActivityThread.java:4745)
08-19 05:55:43.271: W/System.err(1458):     at java.lang.reflect.Method.invokeNative(Native Method)
08-19 05:55:43.271: W/System.err(1458):     at java.lang.reflect.Method.invoke(Method.java:511)
08-19 05:55:43.271: W/System.err(1458):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-19 05:55:43.271: W/System.err(1458):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-19 05:55:43.271: W/System.err(1458):     at dalvik.system.NativeStart.main(Native Method)

I want to load gif image from sdcard. How to solve this? If the gif image in drawable folder. its working well. But unable to load from sdcard. Give me the solution.

도움이 되었습니까?

해결책

You need to use InputStream with a BufferSize while loading .GIF images From SDCARD. It'll work for sure.

Follow this link for more Help. Let me know if it's helped.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top