title: How to refresh imageview in android
body: <p>I want to refresh <code>imageview</code> on bytearray received from socket.</p>
  
  <pre><code>new Thread(new Runnable() {
  
              @Override
              public void run() {
                  // TODO Auto-generated method stub
                  while (!socket.isClosed()) {
                      imgArray = receiveImagebytes();
                  }
              }
          }).start();
  
          try {
          Thread.sleep(5000);
      } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  
  while (!socket.isClosed()) {
              runOnUiThread(new Runnable() {
  
                  @Override
                  public void run() {
                      // TODO Auto-generated method stub
  
                      imageView.setImageBitmap(BitmapFactory.decodeByteArray(imgArray, 0, imgArray.length));
                      imageView.invalidate();
                  }
              });
  </code></pre>
  
  <p><code>imgArray</code> is the bytearray received in another thread. I want to refresh the imageview..But it is not working..It is remaining with same default icon</p>