【发布时间】:2011-09-06 18:35:07
【问题描述】:
我偶尔会收到以下异常。它很少发生,以至于我无法找出可能触发它的任何情况——我主要在其他用户的 Flurry 异常报告中看到它。它可能与退出和返回活动有关(例如,使用 Home 按钮),但这只是一个猜测。
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 布局加载,除了在 VISIBLE 之间切换包含 LinearLayout 之外,我没有以编程方式对其进行任何操作和GONE。基本上,应用程序中唯一的其他内容是两个WebViews,一个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>
在VISIBLE 和GONE 之间切换时,您是否需要对ImageView 进行特殊处理以防止其被回收,或者在回收时检查并刷新它?大多数情况下它都能完美运行。
【问题讨论】:
-
运行进一步测试后,似乎甚至不是我的 ImageView 导致了问题。除非 WebView 使用 ImageViews 做某事,否则我猜它可能与 AdMob 代码或类似代码有关。
标签: android exception canvas bitmap imageview