【发布时间】:2015-02-15 04:49:33
【问题描述】:
我正在尝试通过 JSON 数据获取图像 URL,它成功运行。下面的一切工作缓慢。但是,我正在尝试找出一种方法来让 URL 在 Android Volley 或其他快速方法中显示得更快。我正在尝试将这些图像从 URL(也已调整大小)下载到 MapView pin 图标中。如果有任何人都能找到更有效的示例,我全力以赴。如果您需要我提供更多信息,请告诉我。我正在关注本指南: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);
【问题讨论】:
标签: java android json asynchronous android-volley