最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android從服務(wù)器獲取圖片的實(shí)例方法

 更新時(shí)間:2013年06月04日 10:48:39   作者:  
Android從服務(wù)器獲取圖片的實(shí)例方法,需要的朋友可以參考一下

[java]

復(fù)制代碼 代碼如下:

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);   // 關(guān)鍵是這句代碼 

    } 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);   // 關(guān)鍵是這句代碼

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


其中imagePath是你的圖片路徑,


最后可以將圖片顯示在手機(jī)上:


[java]

復(fù)制代碼 代碼如下:

imageView.setImageBitmap(bitmap);

相關(guān)文章

最新評論

日喀则市| 屏山县| 陇南市| 合江县| 峡江县| 天镇县| 嫩江县| 东莞市| 和平区| 开化县| 绥德县| 万山特区| 邻水| 乳山市| 嘉禾县| 拜泉县| 措勤县| 拜泉县| 遵义县| 财经| 汉源县| 高要市| 新乐市| 曲靖市| 新绛县| 乌审旗| 京山县| 鄂伦春自治旗| 长沙县| 于都县| 沅陵县| 工布江达县| 荥经县| 金塔县| 侯马市| 忻州市| 延边| 弋阳县| 桦川县| 南宫市| 三江|