从服务器上取到图片地址,比如image/XXX/1233455.JPG 然后自己定义一个字符串baseUrl = 10.0.2.2:8080/Demo/ ,和取到的地址拼起来。总之意思就是你不是直接得到图片,而是得到图片的地址,然后根据地址取出来图片。比如: // 传输网络图片
public Bitmap getPic(String uriPic) {
URL imageUrl = null;
Bitmap bitmap = null;
try {
imageUrl = new URL(uriPic);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) imageUrl
.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is); is.close(); } catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}取到后相对图片再做处理的话就 bmp = Bitmap.createScaledBitmap(bmp, 长,宽,
true);
public Bitmap getPic(String uriPic) {
URL imageUrl = null;
Bitmap bitmap = null;
try {
imageUrl = new URL(uriPic);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) imageUrl
.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is); is.close(); } catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}取到后相对图片再做处理的话就 bmp = Bitmap.createScaledBitmap(bmp, 长,宽,
true);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货