试图使用回收的位图

时间:2015-02-23 07:21:06

标签: android

我不知道如何解决这种类型的异常.. 请帮帮我......

02-23 12:36:00.705: E/AndroidRuntime(2033): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@41214638
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

2 个答案:

答案 0 :(得分:0)

不要使用回收的位图。如果需要检查,请在使用可能的位图之前使用isRecycled函数,如果返回true则避免使用它。

答案 1 :(得分:0)

如果您的位图在屏幕上使用,请不要致电bitmap.recycle()。如果你这称呼它将导致异常