I'm very occasionally receiving the开发者_JAVA百科 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 WebView
s, 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.
This exception was caused by an advertising SDK, and has been fixed in a recent SDK release.
精彩评论