0

in my app I am getting the byte[] from server and I need to show it on imageview so I wrote this code:

byte[] im = allUsers.get(i).getPhoto().getBytes();
Bitmap bmp = BitmapFactory.decodeByteArray(im, 0, im.length);
((ImageView) dialog.findViewById(R.id.image)).setImageBitmap(bmp);

But bmp is always null. So what can be the problem?

HK.avdalyan
  • 724
  • 1
  • 6
  • 21
  • It's hard to tell with out the rest of your code. It is possible the bytes coming from the server are not complete or corrupted. It is also possible you made an issue while loading the bytes. –  Apr 22 '14 at 21:14
  • That's way too broad, you need to make sure the byte array is actually containing the image first, also take a look at the logs in case it returns some sort of message of what went wrong with decoding the byte array... – Martin Cazares Apr 22 '14 at 21:14
  • duplicate of http://stackoverflow.com/questions/6520745/why-does-bitmapfactory-decodebytearray-return-null – ditkin Apr 22 '14 at 21:15
  • Solved there was a problem with coming byte array – HK.avdalyan Apr 23 '14 at 09:33

0 Answers0