android获取网络图片代码

public static Bitmap getImage(String path) throws Exception

   {

      URL m_URL=new URL(path);

      HttpURLConnection conn=(HttpURLConnection)m_URL.openConnection();

      conn.setConnectTimeout(5000);

      conn.setRequestMethod("GET");

      if(conn.getResponseCode()==200)

      {

         InputStream inStream=conn.getInputStream();

         Bitmap bitmap=BitmapFactory.decodeStream(inStream);

         return bitmap;

      }

      return null;

   }


猜你喜欢

转载自blog.csdn.net/xw_spark/article/details/8540490