I want to refresh imageview on bytearray received from socket.
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();
}
});
imgArray 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
Sorry to all.The problem was that the above code was in the main thread,thus got blocking all responses to the UI.
The problem got solved when I moved the code to a thread from the main thread.Now it is working correctly.
Thanks for all replies