I have to download an image from server.But I got an error "D/skia ( 197): xxxxxxxxxxx jpeg error 53 Not a JPEG file: starts with 0x%02x 0x%02x"
I have to perform two continues Http connection.First is used to get server response and second to get image from the server.First task is performed correctly but while downloading image I got the given eror.So the problem in getting image from server.
My code is:
- Code: Select all
public ImageView getView(String myImageURL) {
Log.i("TAG","downloadFile000000000000000000"+myImageURL);
ImageView i = new ImageView(this);
try {
/* Open a new URL and get the InputStream to load data from it. */
URL aURL = new URL(myImageURL);
URLConnection conn = aURL.openConnection();
Log.i("TAG","downloadFile1111111111111111111"+myImageURL);
conn.connect();
InputStream is = conn.getInputStream();
Log.i("TAG","downloadFile2222222222222222222222"+is.read());
/* Buffered is always good for a performance plus. */
BufferedInputStream bis = new BufferedInputStream(is);
Log.i("TAG","downloadFile33333333333333333333="+bis.read());
/* Decode url-data to a bitmap. */
// Bitmap bm = BitmapFactory.decodeStream(bis);
Bitmap bm = BitmapFactory.decodeStream(is);
// Log.i("TAG","downloadFile4444444444444444444"+bm.getHeight());
// bis.close();
is.close();
/* Apply the Bitmap to the ImageView that will be returned. */
i.setImageBitmap(bm);
Log.i("TAG","downloadFile555555555555555555555");
} catch (IOException e) {
Log.i("TAG","downloadFile666666666666666666666666");
Log.e("DEBUGTAG", "Remtoe Image Exception", e);
}
/* Image should be scaled as width/height are set. */
// i.setScaleType(ImageView.ScaleType.FIT_CENTER);
/* Set the Width/Height of the ImageView. */
return i;
}
This code works fine when I performed this task alone in another project.



Google Weather Tutorial 

