bitmap size exceeds VM budget

 

bitmap size exceeds VM budget
10-19 16:20:44.617: ERROR/AndroidRuntime(13274):
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:498)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:473)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:715)
at android.content.res.Resources.loadDrawable(Resources.java:1713)
at android.content.res.Resources.getDrawable(Resources.java:585)
at cn.sinonet.uhome.ui.bulbcurtain.util.BmpUtil.getBmpByResid(BmpUtil.java:12)
at cn.sinonet.uhome.ui.bulbcurtain.util.BmpUtil.getBmpByWidth(BmpUtil.java:19)
at cn.sinonet.uhome.ui.bulbcurtain.view.UnscaledLight.loadSwitchBgBmp(UnscaledLight.java:247)
at cn.sinonet.uhome.ui.bulbcurtain.view.UnscaledLight.loadBmp(UnscaledLight.java:221)
at cn.sinonet.uhome.ui.bulbcurtain.view.UnscaledLight.onDraw(UnscaledLight.java:205)

  点击返回键时回收图片内存资源

 

	void recycleBmp(Bitmap bmp)
	{
		if(bmp != null && !bmp.isRecycled())
			bmp.recycle();
	}
	
	void recycleBmp()
	{
		recycleBmp(bmpBg);
		recycleBmp(bmpSwitchBg);
		recycleBmp(bmpSwitchOn);
		recycleBmp(bmpSwitchOff);
		recycleBmp(bmpSwitch);
		recycleBmp(bmpBulbOn);
		recycleBmp(bmpBulbOff);
		recycleBmp(bmpBulb);
	}

 

UnscaledLight

 

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if(keyCode == KeyEvent.KEYCODE_BACK)
{
Log.i("smart_home", "++UnscaledLight.onKeyDown++");
recycleBmp();
}
return super.onKeyDown(keyCode, event);
}

 

 SmartUHomeActivity

 

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
Log.i("smart_home", "++SmartHomeActivity.onKeyDown++");
}
Log.i("smart_home", "super.onKeyDown::" + super.onKeyDown(keyCode, event));
// return super.onKeyDown(keyCode, event);
return false;
}
LOG日志
10-19 17:00:56.762: INFO/smart_home(16185): ++SmartHomeActivity.onKeyDown++
10-19 17:00:56.772: INFO/smart_home(16185): super.onKeyDown::true

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值