android项目中问题汇总

1、图片加载超过20M,直接程序崩溃

10-10 17:58:39.940: E/dalvikvm(14548): GC_FOR_ALLOC freed 79K, 13% free 35752K/40647K, paused 15ms+6ms, total 84ms

10-10 17:58:40.000: E/dalvikvm(14548): GC_BEFORE_OOM freed 12K, 13% free 35740K/40647K, paused 64ms, total 64ms
10-10 17:58:40.000: E/dalvikvm-heap(14548): Out of memory on a 20155408-byte allocation.

错误做法:

setImageBitmap或setImageResource或BitmapFactory.decodeResource来设置一张大图
Drawable.createFromPath

正确做法:

InputStream is = this.getResources().openRawResource(R.drawable.pic1);
     BitmapFactory.Options options=new BitmapFactory.Options();
     options.inJustDecodeBounds = false;
     options.inSampleSize = 10;   //width,hight设为原来的十分一
     Bitmap btp =BitmapFactory.decodeStream(is,null,options);
2. if(!bmp.isRecycle() ){
         bmp.recycle()   //回收图片所占的内存
         system.gc()  //提醒系统及时回收

2、webview优化渲染效率

几种加速WebView加载的方法,提高渲染的优先级

webView.getSettings().setRenderPriority(RenderPriority.HIGH); 

使用webView.getSettings().setBlockNetworkImage,把图片加载放在最后来加载渲染webView.getSettings().setBlockNetworkImage(true); 


3、 android项目中问题汇总 - 87426628 - 小鱼的博客

4、Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@431a5508: Unmarshalling unknown type code 260 at offset 384
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值