/** * The system calls this to perform work in a worker thread and delivers it the parameters given * to AsyncTask.execute() */ protected Article doInBackground(Integer... headlinePageNumber) { // Get basic article info from internet Article article = FetchHeadlineArticles.getArticles("featured", headlinePageNumber[0]); try { byte[] bytes; // Lowers resolution of images by subsampling image, saves memory & time BitmapFactory.Options a = new BitmapFactory.Options(); a.inSampleSize = 1; // Download image from website InputStream in = new URL(article.getImageURL()).openStream(); // Save bitmap here article.setBitmap(BitmapFactory.decodeStream(in, null, a)); } catch (IOException e) { Log.e("HEADLINE IMAGE DOWNLOAD", e.getMessage()); } return article; }