Android : Convert Byte array to bitmap not working - android

on Tuesday, March 24, 2015


I have a web service written in vb.net, with it i retrieve an image (blob) from my mysql database. I convert it to byte() and treat it with my android app (written in eclipse) where i just need to show it, therefore for use it in an imageview.





class AsyncCallWS3 extends AsyncTask<String, Void, String> {

ImageView img;

public AsyncCallWS3(ImageView img) {
// TODO Auto-generated constructor stub
this.img = img;
}

@Override
protected String doInBackground(String... params) {

String result;
result = SponsorWebService.getSponsor("getDetails", "abed", "kader");
this.Execute();
return result;
}
protected void Execute(){
String result;
byte[] byteArray;
result = ImageService.getImage("ralph", "kesrouani","getImage");

byteArray = result.getBytes();
final BitmapFactory.Options options = new BitmapFactory.Options();


options.inJustDecodeBounds = true;
options.inSampleSize = 64;
Bitmap bm = BitmapFactory.decodeByteArray(byteArray,0,byteArray.length,options);

img.setImageBitmap(bm);

}
}



This is my asynctask where i called a java class and using soap i retrieve the string, convert to byte, convert then to bitmap. But when converting to bitmap i get a null value.


Please i've been on this for days and i can't find any help on the web. I can give you extra info about the code. Thanks


0 comments:

Post a Comment