Created
October 10, 2013 07:30
-
-
Save zackexplosion/6914413 to your computer and use it in GitHub Desktop.
android load image from url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL url = null; | |
Bitmap bmp = null; | |
try { | |
url = new URL("https://avatars.plurk.com/3779689-big44.jpg"); | |
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream()); | |
} catch (MalformedURLException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
ImageView imageView = (ImageView)findViewById(R.id.imageView1); | |
if(bmp != null){ | |
imageView.setImageBitmap(bmp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment