public static Bitmap downloadfile(String fileurl) {
Bitmap bmImg = null;
URL myfileurl = null;
try {
myfileurl = new URL(fileurl);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) myfileurl
.openConnection();
conn.setDoInput(true);
conn.connect();
int length = conn.getContentLength();
if (length > 0) {
int[] bitmapData = new int[length];
byte[] bitmapData2 = new byte[length];
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
} else {
}
} catch (IOException e) {
}
return bmImg;
}
mysql의 이미지를 안드로이드에서 보여주기 위해서
mysql에는 파일의 위치를 저장해두고 php를 이용해서 위치를 안드로이드로 가져왔습니다.
그 후 안드로이드에서 위 메소드를 이용해서 이미지를 비트맵으로 뿌려주려고 했는데
이미지 출력이 되지 않습니다.
로그캣에는 SkImageDecoder::Factory returned null이라고 나오는데 왜 안되는지 모르겠습니다.......
이미지 위치는 http://서버주소/폴더명/파일명.jpg 이런식 입니다.