android - display bitmap setImageBitmap -
in application android, trying receive image server socket, can't display them setimagebitmap(). don't have error, screen stay white. here code :
public class communicateurandroid implements runnable { public communicateurandroid(socket s, imageview img) { _imagev = img; try { _din = new datainputstream(s.getinputstream()); _dout = new dataoutputstream(s.getoutputstream()); } catch (ioexception e) { e.printstacktrace(); } new thread(this).start(); } public void run() { int length = 0; byte tmp; while (true) try { length = _din.readint(); byte tab[] = new byte[length]; (int = 0; < length; i++) { tmp = _din.readbyte(); tab[i] = tmp; } _image = bitmapfactory.decodebytearray(tab, 0, tab.length); system.out.println("----------"); if (_image != null) { _imagev.setimagebitmap(_image); system.out.println("test"); thread.sleep(5000); } } catch (ioexception e) { e.printstacktrace(); } catch (interruptedexception e) { e.printstacktrace(); } } public bitmap get_image() { return _image; } private datainputstream _din; private dataoutputstream _dout; private bitmap _image; private imageview _imagev; }
i call constructor line
new communicateurandroid(_socket, (imageview) findviewbyid(r.id.imageview3_left));
can me?
the best way receive images server , displaying them, use android-universal-image-loader library.
i using in applications , best solution problem.
Comments
Post a Comment