From bb052f1370ae38fa2c00947bba11cc1635979f88 Mon Sep 17 00:00:00 2001 From: liujinwei Date: Mon, 15 Apr 2019 11:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BE=AE=E4=BF=A1=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E5=9B=BE=E7=89=87=E5=81=B6=E7=8E=B0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=A2=AB=E5=9B=9E=E6=94=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/net/arvin/socialhelper/SocialUtil.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/socialhelper/src/main/java/net/arvin/socialhelper/SocialUtil.java b/socialhelper/src/main/java/net/arvin/socialhelper/SocialUtil.java index 1b24096..14d3a87 100644 --- a/socialhelper/src/main/java/net/arvin/socialhelper/SocialUtil.java +++ b/socialhelper/src/main/java/net/arvin/socialhelper/SocialUtil.java @@ -73,23 +73,29 @@ static byte[] bmpToByteArray(final Bitmap bmp, boolean needThumb) { height = 150; } newBmp = Bitmap.createScaledBitmap(bmp, width, height, true); - bmp.recycle(); } else { newBmp = bmp; } ByteArrayOutputStream output = new ByteArrayOutputStream(); newBmp.compress(Bitmap.CompressFormat.JPEG, 100, output); - newBmp.recycle(); byte[] result = output.toByteArray(); try { output.close(); } catch (Exception e) { e.printStackTrace(); + } finally { + if (!bmp.isRecycled()) { + bmp.recycle(); + } + if (!newBmp.isRecycled()) { + newBmp.recycle(); + } } return result; } + /** * 是否安装qq */