Hi, I'm trying to display an image using a URL. When I run the code I
get an error telling me the application has stopped unexpectedly. Can
anyone see what's wrong in my code.
Bitmap bmImg;
URL myFileUrl =null;
try {
myFileUrl= new
URL("http://www.starling-fitness.com/wp-content/
240384vBdA_w.jpg");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
URLConnection conn=
(URLConnection)myFileUrl.openConnection();
conn.setDoInput(true);
conn.connect();
int length = conn.getContentLength();
int[] bitmapData = new int[length];
byte[] bitmapData2 = new byte[length];
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
/*timetableImage.setImageBitmap(bmImg);*/
setContentView(R.layout.timetable);
ImageView iv =
(ImageView)findViewById(R.id.timetableImage);
iv.setImageBitmap(bmImg);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---