We won't know what's going on unless you show us a strack-trace of the
error. :=)
Look at LogCat and copy/paste the strack-trace in this thread.

All i can do now is guess:
How big is your image?
You create two arrays (int[] and byte[]) which are never used. This is
memory waste.
The inputstream 'is' may hold a large image as well.
You may have gotten a out-of-memory error or an error occurring
because you exceeded the allowed bitmap allocation budget.



On Mar 23, 11:49 am, murphy <[email protected]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to