[android-developers] I am trying to set the Image for an ImageView any help would be great

2012-11-28 Thread Gabriel Higareda
Sorry to be posting but I can't see my posts on the group page: This is the 
code that is giving me trouble: 

try{
URL url = new 
URL("http://en.wikipedia.org/wiki/File:Polar_Bear_-_Alaska.jpg";);
HttpURLConnection connection  = (HttpURLConnection) 
url.openConnection();

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);  

animalPhoto.setImageBitmap(img );
}catch(Exception e){
Toast.makeText(this,"IO Exception", Toast.LENGTH_LONG).show(); 
}

But when i run my app, no picture is shown and my catch message shows... 
Not sure what is going on. 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] I am trying to set the Image for an ImageView any help would be great

2012-11-28 Thread Marina Cuello
That's not the link to the image, but to the image info. The link to
the high res image is
http://upload.wikimedia.org/wikipedia/commons/0/09/Polar_Bear_-_Alaska.jpg
You could have found it as I did... just following your own link.

Marina

On Mon, Nov 26, 2012 at 10:45 PM, Gabriel Higareda  wrote:
> Sorry to be posting but I can't see my posts on the group page: This is the
> code that is giving me trouble:
>
> try{
> URL url = new
> URL("http://en.wikipedia.org/wiki/File:Polar_Bear_-_Alaska.jpg";);
> HttpURLConnection connection  = (HttpURLConnection)
> url.openConnection();
>
> InputStream is = connection.getInputStream();
> Bitmap img = BitmapFactory.decodeStream(is);
>
> animalPhoto.setImageBitmap(img );
> }catch(Exception e){
> Toast.makeText(this,"IO Exception", Toast.LENGTH_LONG).show();
> }
>
> But when i run my app, no picture is shown and my catch message shows... Not
> sure what is going on.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] I am trying to set the Image for an ImageView any help would be great

2012-11-28 Thread TreKing
On Mon, Nov 26, 2012 at 7:45 PM, Gabriel Higareda wrote:

> But when i run my app, no picture is shown and my catch message shows...
> Not sure what is going on.


You might consider printing the actual error message from the exception,
instead of writing out "IO Exception", which it might not even be.
This will probably give you a better idea what your issues are.
Also, the debugger is your friend.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en