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 */