a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 系統(tǒng) > Android > 正文

Android從服務器獲取圖片的實例方法

2020-04-11 12:15:43
字體:
來源:轉載
供稿:網友

[java]

復制代碼 代碼如下:

public static Bitmap getBitmapFromServer(String imagePath) {

    HttpGet get = new HttpGet(imagePath);
    HttpClient client = new DefaultHttpClient();
    Bitmap pic = null;
    try {
        HttpResponse response = client.execute(get);
        HttpEntity entity = response.getEntity();
        InputStream is = entity.getContent();

        pic = BitmapFactory.decodeStream(is);   // 關鍵是這句代碼 

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return pic;
}

 public static Bitmap getBitmapFromServer(String imagePath) {

  HttpGet get = new HttpGet(imagePath);
  HttpClient client = new DefaultHttpClient();
  Bitmap pic = null;
  try {
   HttpResponse response = client.execute(get);
   HttpEntity entity = response.getEntity();
   InputStream is = entity.getContent();

   pic = BitmapFactory.decodeStream(is);   // 關鍵是這句代碼

  } catch (ClientProtocolException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  return pic;
 }


其中imagePath是你的圖片路徑,


最后可以將圖片顯示在手機上:


[java]

復制代碼 代碼如下:

imageView.setImageBitmap(bitmap);

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 五月天婷婷国产精品 | 国产精品一二三区 | 久久亚洲欧美日韩精品专区 | 免费毛片视频 | 黄色一级毛片免费 | 国产精品国产自产拍高清 | 欧洲一区二区视频 | 人人艹人人 | 97久久精品人人做人人爽50路 | 精东粉嫩av免费一区二区三区 | 蜜桃av中文字幕 | 亚洲精品视频在线播放 | 一区二区三区在线免费观看 | 免费色在线 | 午夜免费福利视频 | 男女免费视频 | 日韩精品一区二区三区中文字幕 | 久久久久久久伦理 | 日韩一区二区三区在线观看 | 久久成人免费网站 | 欧美乱码精品一区二区三 | 精品免费 | 久久久久中文字幕 | 久久99亚洲精品久久 | 在线小视频 | 成人a视频在线观看 | 中文字幕国产高清 | 精品国产一区一区二区三亚瑟 | 四虎www4hu永久免费 | 久久人| 天堂影院一区二区 | 欧美午夜精品理论片a级按摩 | 日韩一区二区在线视频 | 国产伦精品一区二区三区照片91 | 女人高潮特级毛片 | 欧美xxxx网站 | 久久久久亚洲精品 | 亚洲八区 | 日韩在线www| 国产九九九 | 国产欧美精品一区二区三区四区 |