我偶尔会收到以下异常。它很少发生,以至于我无法找出可能触发它的任何情况——我主要是在其他用户的 Flurry 异常报告中看到它。它可能与退出和返回 Activity 有关(例如使用主页按钮),但这只是一个猜测。
class java.lang.RuntimeException android.graphics.Canvas.throwIfRecycled:955 (Canvas: trying to use a recycled bitmap android.graphics.Bitmap@30095b30)
此处完整的 LogCat 转储:http://pastebin.com/2RjjgWHH
我查看了相关问题,但似乎都不适用。问题是,我没有手动回收任何位图。我没有加载大位图或操作位图。我有一个单例,很小 ImageView
我整个应用程序中的图标,从 XML 布局加载,除了切换包含 LinearLayout
之外,我没有以编程方式对它做任何事情。在 VISIBLE
之间和 GONE
.基本上应用程序中唯一的其他东西是两个 WebView
一个TextView
和一个 ProgressDialog
.
<ImageView android:id="@+id/imageView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon_a" android:focusableInTouchMode="false" android:focusable="false" android:layout_gravity="center_horizontal"></ImageView>
您需要对 ImageView
做些什么特别的事情吗?防止它被回收,或者在 VISIBLE
之间切换时检查并刷新它是否被回收和 GONE
?大多数情况下它都能完美运行。
最佳答案
此异常是由广告 SDK 引起的,已在最近的 SDK 版本中修复。
关于android - ImageView 导致 android.graphics.Canvas.throwIfRecycled 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6209745/