http 응답에서 이미지를 가져 오려고하지만 스트림을 비트 맵으로 변환하지 못했습니다. 알려주십시오. 여기에 무엇이 없습니까?Android의 httpResponse에서 이미지 콘텐츠 가져 오기
참고 - 이미지 콘텐츠는 원시 이진 & 이미지와 jpeg 이미지로 수신됩니다.
절차는 다음 :
- 만들기 HttpRequest에 있습니다.
- 응답에서 200 -> http 내용을 확인하십시오.
- BitMap 팩토리를 사용하여 스트림을 비트 맵으로 변환합니다.
- 사전에 AsyncTask를
if (null != instream) { Bitmap bm = BitmapFactory.decodeStream(instream); if(null == bm){ Toast toast = Toast.makeText(getApplicationContext(), "Bitmap is NULL", Toast.LENGTH_SHORT); toast.show(); } ImageView view = (ImageView) findViewById(R.id.picture_frame); view.setImageBitmap(bm); }
감사의 postExecute이를하고 AsyncTask를
HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(endpoint); // Adding Headers .. // Execute the request HttpResponse response; try { response = httpclient.execute(httpget); if (response.getStatusLine().getStatusCode() == 200) { // Get hold of the response entity HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); return instream; // instream.close(); } } }
의 postExecute에 이렇게
를 이미지 뷰에 비트 맵을 설정합니다.
감사합니다. 다른 라이브러리를 사용하고 싶지 않습니다. 단일 라이브러리에서 처리되는 모든 요청 및 응답을 수행하기위한 것입니다. – Dinesh