【Android开发经验】Cannot generate texture from bitmap异常的解决方式
异常现象:
今天在处理用户头像的过程中,由于头像的处理比較复杂,由于,没有使用afinal自带的自己主动载入。而是自己依据头像的下载路径。手动进行下载和使用。可是在手动回收bitmap对象的过程中,会出现Cannot generate texture from bitmap异常的情况,同一时候,ImageView显示是黑色的,图像不能正常显示。
解决方式:
在查阅了一些其它人的资料之后,发现这可能是因为4.0之后系统开启了GPU硬件加速导致的。因此,我们能够在图片载入之前,设置ImageView为关闭硬件加速状态。因此,我们能够用以下的代码完毕。
if (SystemUtils.getSystemVersion() >= SystemUtils.V4_0) {
img_header.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
之所以要加上版本号控制。是由于设置图片的非硬件加速模式是在api11之后加入的,因此,我们须要进行版本号的控制,否则。在低版本号上执行会报错。
以下是检測版本号的帮助类SystemUtils.java
/**
*
* @ClassName: com.drd.piaojubao.utils.SystemUtils
* @Description: 当前平台系统的工具类
* @author zhaokaiqiang
* @date 2014-10-11 上午9:51:47
*
*/
public class SystemUtils { public static final int V2_2 = 8;
public static final int V2_3 = 9;
public static final int V2_3_3 = 10;
public static final int V3_0 = 11;
public static final int V3_1 = 12;
public static final int V3_2 = 13;
public static final int V4_0 = 14;
public static final int V4_0_3 = 15;
public static final int V4_1 = 16;
public static final int V4_2 = 17;
public static final int V4_3 = 18;
public static final int V4_4 = 19; /**
*
* @Description: 检測当前的版本号信息
* @param
* @return int
* @throws
*/
public static int getSystemVersion() {
return android.os.Build.VERSION.SDK_INT;
} }
【Android开发经验】Cannot generate texture from bitmap异常的解决方式的更多相关文章
- 连接db2数据库时NumberFormatException异常的解决方式
连接db2数据库时报异常:java.lang.NumberFormatException: For input string: "A" from a DB2 JDBC(JCC) j ...
- Hadoop常见异常及其解决方式
1.Shell$ExitCodeException 现象:执行hadoop job时出现例如以下异常: 14/07/09 14:42:50 INFO mapreduce.Job: Task Id : ...
- android EditText 限定中文个数与英文个数的解决方式
EditText 限定中文8个英文16个的解决方法. 在EditText上控件提供的属性中有限定最大最小长度的方法. 可是,对于输入时,限定中文8个英文16个时,怎么办?相当于一个中文的长度是两个英文 ...
- dubbo常见异常及解决方式
1.出现RpcException: Failed to invoke the method post in the service com.xxx.xxx.xxx异常怎么办?表示调用失败1.检查网络是 ...
- celery出现警告或异常的解决方式
做个笔记,记录下使用celery踩过的坑,不定期更新. warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED)) 我用的是Flask,所以在Fl ...
- Android Studio 错误: 非法字符: '\ufeff' 解决方式|错误: 须要class, interface或enum
在导入eclipse项目到Android Studio出现这种错误, 非法字符: '\ufeff' 解决方式|错误: 须要class, interface或enum.查阅后了解到Eclipse能够智能 ...
- android通过BitmapFactory.decodeFile获取图片bitmap报内存溢出的解决办法
android通过BitmapFactory.decodeFile获取图片bitmap报内存溢出的解决办法 原方法: public static Bitmap getSmallBitmap(Strin ...
- 【我的Android进阶之旅】 RxJava 理解Backpressure并解决异常 rx.exceptions.MissingBackpressureException
今天测试人员在测试应用APP的时候应用crash了,查看了下crash log如下所示: java.lang.IllegalStateException: Exception thrown on Sc ...
- Android开发之高效加载Bitmap
一.概述 在Android开发中,我们经常与Bitmap打交道,而对Bitmap的不恰当的操作经常会导致OOM(Out of Memory).这篇文章我们会介绍如何高效地在Android开发中使用Bi ...
随机推荐
- iptables详解与Centos7 关闭防火墙
http://www.cnblogs.com/metoy/p/4320813.html CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下 1.直接关闭防 ...
- mysql 源代码讲解
http://www.zhdba.com/mysqlops/category/mysql-source-code/
- MyEclipse项目如何导入到Eclipse
1.请首先确保你的eclipse是javaee版本的,或者已经安装看wtp插件 2.然后修改eclipse工程下的.project文件: 3.在<natures></natures& ...
- Visual Studio 2017 简体中文企业正式版全量离线安装包下载地址
Visual Studio 2017 简体中文企业正式版全量离线安装包下载地址:magnet:?xt=urn:btih:199993649B1834C50FE7BDD204502CC23C7A4611 ...
- 【Burnside定理】&【Pólya定理】
Burnside & Pólya (详细内容请参阅<组合数学>或2008年cyx的论文,这里只写一些我学习的时候理解困难的几个点,觉得我SB的请轻鄙视……如果有觉得不科学的地方欢迎 ...
- 【BZOJ】【3503】【CQOI2014】和谐矩阵
高斯消元解Xor方程组 Orz ZYF o(︶︿︶)o 唉我的数学太烂了…… 错误思路:对每个格点进行标号,然后根据某5个异或和为0列方程组,高斯消元找自由元……(目测N^3会TLE) ZYF的正确思 ...
- Java://Comparator、Comparable的用法(按照要求将set集合的数据进行排序输出):
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; //comparator. ...
- 用过Retina视网膜屏幕的笔记本电脑的后果
用过Retina视网膜屏幕的笔记本电脑的后果是过程中感觉很不错,但是结果是普通屏幕再也看不上眼了.发现了原来看的好好的屏幕多出了许多的像素点,没办法,火眼金睛了.
- Android完全退出程序、线程
1.先添加权限 <uses-permission android:name="android.permission.RESTART_PACKAGES" /> 2.添加A ...
- Substring with Concatenation of All Words leetcode java
题目: You are given a string, S, and a list of words, L, that are all of the same length. Find all sta ...