undercoverindian
12/27/2017 - 12:44 AM

ImageView

Assign image to an ImageView

Main Activity ->  new LoadImageFromUrl().execute(photoURL.toString());

public class LoadImageFromUrl extends AsyncTask <Object, String, Bitmap> {

  @Override
  protected Bitmap doInBackground(Object[] objects) {

      try {

          URL url = new URL(objects[0]);
          Bitmap bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream());
          Log.d("Success", "yay");
          return bitmap;

      } catch (Exception e) { }

      return null;
  }

  @Override
  protected void onPostExecute(Bitmap bitmap) {
      super.onPostExecute(bitmap);
      image.setImageBitmap(bitmap);
  }
}
android:src="@drawable/image"