I’ll make my usual yammering quick so you can get straight to the good stuff. This is just a snippet to show you how you can display an image from the Internet in your native Android app via ImageView. This is ideal in a few situations, namely when you need to keep app size and initial load time down, or if it isn’t feasible to locally store all the images your app will use.
packagecom.savagelook;importjava.io.IOException;importjava.io.InputStream;importjava.net.MalformedURLException;importjava.net.URL;importandroid.app.Activity;importandroid.graphics.drawable.Drawable;importandroid.os.Bundle;importandroid.widget.ImageView;publicclassShowImageActivityextendsActivity{@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);// YOUR_LAYOUT is the name of your layout resource// IMAGEVIEW_ID is your ImageView in YOUR_LAYOUTsetContentView(R.layout.YOUR_LAYOUT);ImageViewimageView=(ImageView)findViewById(R.id.IMAGEVIEW_ID);imageView.setImageDrawable(createDrawableFromURL("http://savagelook.com/misc/sl_drop2.png"));}privateDrawablecreateDrawableFromURL(StringurlString){Drawableimage=null;try{URLurl=newURL(urlString);InputStreamis=(InputStream)url.getContent();image=Drawable.createFromStream(is,"src");}catch(MalformedURLExceptione){// handle URL exceptionimage=null;}catch(IOExceptione){// handle InputStream exceptionimage=null;}returnimage;}}