본문 바로가기
프로그래밍/Android(Java)

[Android] Image Url로부터 Bitmap 받아오기

by 쿼카퀀트 2019. 9. 29.
728x90
private static Bitmap getBitmapFromURL(String src) {
    try {
        URL url = new URL(src);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoInput(true);
        connection.connect();
        InputStream input = connection.getInputStream();
        Bitmap myBitmap = BitmapFactory.decodeStream(input);
        return myBitmap;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
728x90

댓글