Use HttpUrlConnection to load network images,
Use HttpUrlConnection to load network images
Private Context context; private Button button; private ImageView imageView; // Bitmap object private Bitmap bitmap is required for loading network images; public DownloadImageTask (Context context, Button button, ImageView imageView) {this. context = context; this. button = button; this. imageView = imageView;} @ Override protected Bitmap doInBackground (String... strings) {Bitmap bitmap = null; try {URL url = new URL (strings [0]); HttpURLConnection httpURLConnection = (HttpURLConnection) url. openConnection (); InputStream inputStream = httpURLConnection. getInputStream (); bitmap = BitmapFactory. decodeStream (inputStream);} catch (MalformedURLException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();} return bitmap;} @ Override protected void onPostExecute (Bitmap bitmap) {super. onPostExecute (bitmap); imageView. setImageBitmap (bitmap );}