Good morning,
I have a .Net web service that return a byte[](actually its an image). How can i read this byte[] array and in code convert it to an image an display it in a ImageView.
In some way the ImageView.setImageBitmap(Bitmap) method will probably be involved, so you should read up on how to create suitable Bitmap objects; the setPixel/setPixels methods seem particularly relevant.
i finally got the code to work. but a weird thing is going on, on the emulator this code
try
{
byte[] myImage = gemyImage();
Bitmap bmp=BitmapFactory.decodeByteArray(myImage,0,myImage.length);
if (bmp!=null)
{
ImageView myView = (ImageView)findViewById(R.id.myImage);
myView.setImageBitmap(bmp);
}
}
catch (Exception e)
{
Log.e("Create file error : ",e.getMessage());
}
that displays the image that i get from the webservice works, when i copy the app to a device with 2.1 on it just crashes. no errors can be viewed. any idea why this is happening?
...it just crashes. no errors can be viewed. any idea why this is happening?
This sounds odd. Whenever Android sees fit to terminate an application there should always be a message in the logcat output. Which lines of the code you just posted do get executed in the case of the app crashing?
everything else n the app, which is mostly getting data from web services works. When i try to get the image and display it it crashes. The weird thing is that on the emulator it works fine. On my device i dont know what happens. can i test my app on my device and not on the emulator from eclipse? cant see on which line it is crashing because its running on my device...
i think i found what was crashing the app, the emulator has 2.2 version, my device has 2.1 it throws this error
02-24 12:13:42.221: ERROR/AndroidRuntime(341): java.lang.NoClassDefFoundError: android.util.Base64
cant i use the Base64 on older versions?? is there an other utility for older versions?
And, of course, properly select and set the Android SDK version you want to support in your app. Android 2.1 is still quite widespread at this time, so you may want to require at most API level 7.