Skip to content

Instantly share code, notes, and snippets.

@zackexplosion
Created October 10, 2013 07:30
Show Gist options
  • Save zackexplosion/6914413 to your computer and use it in GitHub Desktop.
Save zackexplosion/6914413 to your computer and use it in GitHub Desktop.
android load image from url
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