【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 ...
随机推荐
- TPS70345 (ACTIVE) 双路输出低压降 (LDO) 稳压器
The TPS703xx family of devices is designed to provide a complete power management solution for TI DS ...
- erlang 中文社区 下载
http://www.cnerlang.com/download/ erlang 下载 http://www.blogjava.net/killme2008/archive/2007/06/1 ...
- Python基础教程学习(三)
如何定义类 class ClassName(base_class[es]): "optional documentation string" static_member_decla ...
- TPL中限制进程数量
The MaxDegreeOfParallelism sets the maximum number of simultaneous threads that will be used for the ...
- DTO vs. Assembly(转载)
DTO vs. Assembly We probably need to make a strong statement about data transfer objects. Do we like ...
- Caused by: org.xml.sax.SAXParseException: The reference to entity "characterEncoding" must end with the ';' delimiter.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Sourc ...
- inline
inline 大学在教科书上学习过inline函数,定义为inline函数之后,会省去函数调用的开销,直接嵌套汇编代码,取代函数调用,提高效率.工作后项目中也很少用到inline来定义函数,近几天在研 ...
- Java:IO流的综合用法(从键盘录入数据并打印在控制台上)
import java.io.*; public class IOTestDouble { public static void main(String[] args)throws Exception ...
- libuv之介绍
本人是在研究linux下socket TCP/IP通讯时,用到了一些linux下的API,比如socket, connect, bind,listen, accept等等,简单写个点对点的通讯,直接用 ...
- ransom-note
https://leetcode.com/problems/ransom-note/ public class Solution { public boolean canConstruct(Strin ...