根据图片的url路径获得Bitmap对象

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;

}

你可能感兴趣的:(根据图片的url路径获得Bitmap对象)