在编码图集过程中,出现了Android IllegalArgumentException: Cannot draw recycled bitmaps错误。

大致意思是:不能使用已经被回收的bitmap。

bitmap回收部分代码如下:

 Bitmap removeBitmap = softReference.get();
if(removeBitmap != null && !removeBitmap.isRecycled()){
removeBitmap.recycle();
removeBitmap = null;
}

解决方法:

重写ImageView中的OnDraw方法,捕获此异常。

 public class MyImageView extends ImageView {  

     public MyImageView (Context context, AttributeSet attrs) {
super(context, attrs);
} @Override
protected void onDraw(Canvas canvas) {
try {
super.onDraw(canvas);
} catch (Exception e) {
System.out.println("trying to use a recycled bitmap");
}
}

Android IllegalArgumentException: Cannot draw recycled bitmaps解决方法的更多相关文章

  1. android 如何分析java.lang.IllegalArgumentException: Cannot draw recycled bitmaps异常

    这类问题的分析,通常你需要找到bitmap对象已经在那个位置recyle,然后检查代码. 如何定位的位置,其中代码具有对bitmap 目的recyle.能够 Bitmap.java的recycle方法 ...

  2. Android SDK Manager 更新失败的解决方法

    Android SDK Manager 更新失败的解决方法 原文地址 最近使用Android SDK Manager 更新Android SDK tools 发现经常更新失败,获取不到更新信息: Fe ...

  3. [转载]关于安装Android Studio的一些问题的解决方法

    最近在研究Android编程,在Android Studio安装和使用时遇到了麻烦,从园子里找到了<关于安装Android Studio的一些问题的解决方法>的,很多问题找到了解决办法. ...

  4. Android使用帧动画内存溢出解决方法

    Android使用帧动画内存溢出解决方法https://blog.csdn.net/daitu_liang/article/details/52336015https://blog.csdn.net/ ...

  5. Android Studio support 26.0.0-alpha1 Failed to resolve: com.android.support:appcompat-v7:27.+ 报错解决方法

    AS下如何生成自定义的.jks签名文件, 以及如何生成数字签名 链接:http://www.cnblogs.com/smyhvae/p/4456420.html 链接:http://blog.csdn ...

  6. [RN] Android 设备adb连接后unauthorized解决方法

    Android 设备adb连接后unauthorized解决方法 安卓设备usb或者adbwireless连接后输入adb device后都是未授权状态 相信很多同学都会遇到这种情况,除了一直重复开关 ...

  7. 备忘-Android ViewPager 与Gallery滑动冲突解决方法

    解决方法,重新定义gallery,禁止触发pager的触摸事件 1 public class UserGallery extends Gallery implements OnGestureListe ...

  8. Rendering Problems:android.support.v7.internal.widget.ActionBarOverlayLayout 解决方法

    不知道是不是android studio安装不对的问题,每次新建项目都有这个问题. 临时解决方法是: 打开 styles.xml 在Theme.AppCompat.Light.DarkActionBa ...

  9. 自己遇到的Android虚拟机出现的错误及解决方法【不断更新】

    2012.11.9 第一个: [2012-11-09 13:15:14 - Tesa] Android Launch! [2012-11-09 13:15:14 - Tesa] The connect ...

随机推荐

  1. Fence Repair POJ - 3253 (贪心)

    Farmer John wants to repair a small length of the fence around the pasture. He measures the fence an ...

  2. linux系统中的时间

    1.编程显示系统时间: #include <stdio.h> #include <time.h> /* gcc -o fix fixedFormatTime.c ./fix * ...

  3. LVM学习笔记

    LVM Logical Volume Manager Volume management creates a layer of abstraction over physical storage, a ...

  4. kali linux 网络渗透测试学习笔记(二)OWASP ZAP工具扫描SQL injection漏洞失败

    按照惯例,利用OWASP ZAP工具扫描SQL injection漏洞时,应该很快就可以扫描出来,但是在笔者进行扫描的时候,却遇到了以下状况: 这说明了该工具根本就没能够扫描出SQL注入的漏洞,不知道 ...

  5. SpringBoot 集成 Swageer2

    添加Maven依赖 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox ...

  6. [Swift]LeetCode86. 分隔链表 | Partition List

    Given a linked list and a value x, partition it such that all nodes less than x come before nodes gr ...

  7. [Swift]LeetCode329. 矩阵中的最长递增路径 | Longest Increasing Path in a Matrix

    Given an integer matrix, find the length of the longest increasing path. From each cell, you can eit ...

  8. [Swift]LeetCode1015. 可被 K 整除的最小整数 | Smallest Integer Divisible by K

    Given a positive integer K, you need find the smallest positive integer N such that N is divisible b ...

  9. Python面试真题第一节

    1.一行代码实现1--100之和 2.如何在一个函数内部修改全局变量 3.列出5个python标准库 4.字典如何删除键和合并两个字典 5.谈下python的GIL 6.python实现列表去重的方法 ...

  10. Identity Server 4 中文文档(v1.0.0) 目录

    欢迎来到IdentityServer4 第一部分 简介 第1章 背景 第2章 术语 第3章 支持和规范 第4章 打包和构建 第5章 支持和咨询选项 第6章 演示服务器和测试 第7章 贡献 第二部分 快 ...