Yenvanio Yenvanio - 1 year ago 40
Android Question

How to get specific images from a website and display them in an Android App?

Given the URL of a website I want to retrieve the logo and background image of the website and display it in an android app. For example from this link I would want the background image and the hack western logo.

EDIT: I forgot to mention I am trying to achieve this effect for a list of URL's of undetermined size until run time

Answer Source

Use this AsyncTask for loading image from URL

 public class LoadImageTask extends AsyncTask<Void, Void, Void>{
    private Bitmap mMyBitmap;
    protected Void doInBackground(Void... params) {
         try {
                URL url = new URL("");
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                InputStream input = connection.getInputStream();
                mMyBitmap = BitmapFactory.decodeStream(input);

            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
            } catch (IOException e) {
                // TODO Auto-generated catch block
        return null;

    protected void onPostExecute(Void result) {


Then call it on OnCreate or somewhere you need:

new LoadImageTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);