2015-02-23 48 views
0

我不知道如何解決這種類型的異常.. 請幫我...試圖用回收的位圖

02-23 12:36:00.705: E/AndroidRuntime(2033): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap [email protected] 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.graphics.Canvas.throwIfRecycled(Canvas.java:1026) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.graphics.Canvas.drawBitmap(Canvas.java:1127) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:393) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.widget.ImageView.onDraw(ImageView.java:979) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13458) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13342) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.drawChild(ViewGroup.java:2929) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13340) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.drawChild(ViewGroup.java:2929) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.widget.AbsListView.dispatchDraw(AbsListView.java:2437) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13461) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.widget.AbsListView.draw(AbsListView.java:3763) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13342) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.drawChild(ViewGroup.java:2929) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13340) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.drawChild(ViewGroup.java:2929) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13340) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.drawChild(ViewGroup.java:2929) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13340) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.drawChild(ViewGroup.java:2929) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.View.draw(View.java:13461) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.widget.FrameLayout.draw(FrameLayout.java:467) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2183) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2258) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewRootImpl.draw(ViewRootImpl.java:2153) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2021) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1832) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.Choreographer.doCallbacks(Choreographer.java:555) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.Choreographer.doFrame(Choreographer.java:525) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.os.Handler.handleCallback(Handler.java:615) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.os.Handler.dispatchMessage(Handler.java:92) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.os.Looper.loop(Looper.java:137) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at android.app.ActivityThread.main(ActivityThread.java:4745) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at java.lang.reflect.Method.invoke(Method.java:511) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
02-23 12:36:00.705: E/AndroidRuntime(2033):  at dalvik.system.NativeStart.main(Native Method) 
02-23 12:36:04.505: I/Process(2033): Sending signal. PID: 2033 SIG: 9 
+0

它被稱爲'RuntimeException'。從技術上講,您不應該操縱回收的位圖來避免此錯誤。你應該使用'bitmap.isRecycled()' – waqaslam 2015-02-23 07:26:21

回答

0

不要使用回收的位圖。如果需要檢查,請在使用位圖之前使用isRecycled函數,並在返回true時避免使用它。

0

如果您的位圖在屏幕上使用,請不要撥打bitmap.recycle()。如果你調用它,將導致異常

+0

非常感謝你.. – 2015-02-23 09:35:52

+0

其工作..錯誤解決... – 2015-02-23 09:36:22