이 메서드를 호출 할 때 항상 NULL이 반환됩니다. 브라우저에서 실행한다고 가정 할 경우 이미지를 표시합니다. public 비트 맵 getBitmapFromURL (String src) { Bitmap bmImg; URL myFileUrl = null;안드로이드에서 이미지를 다운로드 할 수 없습니다.
try {
myFileUrl = new URL("http://www.russiawear.com/components/com_virtuemart/shop_image/product/youth_russia_usa_4e2f7f78b543c.jpg");
HttpURLConnection conn = (HttpURLConnection) myFileUrl
.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
bmImg = BitmapFactory.decodeStream(is, null, options);
return bmImg;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}`
무엇이 문제 일 수 있습니까?
안녕하세요. Gili, 제발이 질문을 게시했을 때 보셨습니까? –
@ NandlalVirani -이 질문은 2 개월 된 사실과 관련하여 위의 의견입니까? 그 질문에 대한 답을 결코 받아들이지 않았기 때문에 다른 사람들이 계속해서 대답하도록하는 것이 이상한 일은 아닙니다. 자신이 답을 찾은 경우 답을 게시하고 수락하여 다른 사용자가 이미 수정 한 문제를 해결하지 않도록 고려하십시오. –