title: Set image coming directly from web server to imageview
body: <p>I am working on ImageView in which I want to set an image into Imageview but that Image(byte array) is coming directly from web server.. The concept is:</p>
  
  <p>1) I am sending various parameteres to web server and in return the web server is sending me an image of that particular ID.(Just an Image, not the URL)</p>
  
  <p>2) Now I want to show that Image directly into ImageView without saving into the SD card, so that whenever the user wants to see any other ID related Image, the Image should come directly from server and we are not saving it at our end.</p>
  
  <p><strong>[Editted]</strong></p>
  
  <p><strong>Fetching value from server and return it in byte[]</strong></p>
  
  <pre><code>     static BufferedReader in=null;
  
  byte[] result_image;
            DefaultHttpClient httpClient = new DefaultHttpClient();
  
          HttpPost httpPost = new HttpPost(uri1);
          if(list!=null)
          {
  
          UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(list);
          httpPost.setEntity(formEntity);
  
          }
           //URI uri=httpPost.getURI();
          HttpResponse httpResponse = httpClient.execute(httpPost);
          in = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
          StringBuffer sb = new StringBuffer("");
          String line = "";
         // String NL = System.getProperty("line.separator");
          while ((line = in.readLine()) != null) {
                sb.append(line +" "); //sb.append(line +NL);
          }
          in.close();
  
  
  
         result_image = String.valueOf(sb).getBytes();
  
  }
      catch(UnsupportedEncodingException e)
      {
          String err = (e.getMessage()==null)?"Cant connect to server":e.getMessage();
          Log.e("Network Error:",err); 
      }
      catch (MalformedURLException e) {
          String err = (e.getMessage()==null)?"Malformed Exception":e.getMessage();
          Log.e("Malformed Exception:",err); 
  
       } 
       catch(Exception ex)
       {
          // Log.i("Exception,ex", ex.getMessage());
           String err = (ex.getMessage()==null)?"NetworkConnectionException":ex.getMessage();
           Log.e("NetworkConnectionException:",err); 
       }
      finally {
  
          if (in != null) {
              try {
                      in.close();
               } catch (Exception ex) {
                   String err = (ex.getMessage()==null)?"Excepion":ex.getMessage();
                   Log.e("Exception:",err); 
              }
          }
  </code></pre>
  
  <p>Here the result_image is a byte [] and using this byte[] am decoding it and shwing it in Bitmap..Please help...
  Any help into this is really appreciated..
  Thanks..</p>