0

I'm attempting to obtain an image URL through JSON data, which works successfully. Everything below works SLOWLY. However, I am trying to figure out a way to get a URL to display much faster below in Android Volley or another fast method. I am trying to download these images from a URL (resized too) into a MapView pin icon. If there is a more efficient example anyone can find, I am all in. Please let me know if you need more information from me. I am following this guide: Android load from URL to Bitmap

final String profilePicture = profilePic;

URL url = new URL(profilePicture);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
Bitmap bit = BitmapFactory.decodeStream(is);
Bitmap b = Bitmap.createScaledBitmap(bit, 100, 100, false);

ByteArrayOutputStream out = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.JPEG, 10, out);
Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));


bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(decoded);
Community
  • 1
  • 1
user2793987
  • 199
  • 1
  • 2
  • 15

2 Answers2

1

Use picasso library :

http://square.github.io/picasso/

Its easy to use and have alot of useful feature !
For example :

Picasso.with(context)
  .load(url)
  .resize(50, 50)
  .centerCrop()
  .into(imageView)
YFeizi
  • 1,498
  • 3
  • 28
  • 50
0

You can use Koushik Ion library. Its very easy to use.

[https://github.com/koush/ion][1]

Meenaxi
  • 567
  • 5
  • 17