I try to get image from internet. Simply i use this code:
public Bitmap getBitmapFromUrl(String src)
{
try
{
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Then when i wan't to launch this code i do this:
this.getBitmapFromUrl("http://icons.iconarchive.com/icons/mazenl77/I-like-buttons-3a/512/Cute-Ball-Go-icon.png");
If i do debug i see that i enter on try, but it's return empty value.
What can i do wrong?
0 comments:
Post a Comment