QQ分享圖片的方法 Bitmap
阿新 • • 發佈:2018-11-12
/** * 根據圖片的url路徑獲得Bitmap物件 * @param url * @return */
private Bitmap returnBitmap(String url) { URL fileUrl = null; Bitmap bitmap = null; try { fileUrl = new URL(url); } catch (MalformedURLException e) { e.printStackTrace(); } try { HttpURLConnection conn = (HttpURLConnection) fileUrl.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); bitmap = BitmapFactory.decodeStream(is); is.close(); } catch (IOException e) { e.printStackTrace(); } return bitmap; }