ImageView 导致 android.graphics.Canvas.throwIfRecycled 异常

发布于 2024-11-11 20:42:28 字数 1144 浏览 0 评论 0 原文

我偶尔会收到以下异常。这种情况很少发生,以至于我无法找出任何可能触发它的情况——我主要在其他用户的 Flurry 异常报告中看到它。它可能与切换出和返回活动(例如使用“主页”按钮)有关,但这只是猜测。

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 布局加载,除了切换包含的 VISIBLEGONE 之间的 >LinearLayout。基本上,应用程序中唯一的其他内容是两个 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>

VISIBLEGONE 之间切换时,您需要对 ImageView 执行一些特殊操作以防止其被回收,或者检查并刷新它(如果被回收) ?大多数时候它工作得很好。

I'm very occasionally receiving the following exception. It occurs so rarely that I haven't been able to figure out any circumstances that might trigger it -- I've mostly seen it in Flurry exception reports from other users. It could potentially be related to switching out of and back to the activity (e.g. with the Home button), but that's only a guess.

class java.lang.RuntimeException    android.graphics.Canvas.throwIfRecycled:955 (Canvas: trying to use a recycled bitmap android.graphics.Bitmap@30095b30)

Full LogCat dump here: http://pastebin.com/2RjjgWHH

I've looked through related questions, but none of them seem to apply. The thing is, I'm not manually recycling any bitmaps. I'm not loading large bitmaps or manipulating bitmaps. I have a single, tiny ImageView icon in my entire app, loaded from an XML layout, and I don't do anything with it programmatically except for switching the containing LinearLayout between VISIBLE and GONE. Basically the only other things in the app are two WebViews, a TextView and a 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>

Is there something special you need to do with an ImageView to keep it from being recycled, or check and refresh it if recycled, when switching it between VISIBLE and GONE? Most of the time it works perfectly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若无相欠,怎会相见 2024-11-18 20:42:28

此异常是由广告 SDK 引起的,并已在最近的 SDK 版本中修复。

This exception was caused by an advertising SDK, and has been fixed in a recent SDK release.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文