常用代码片段(一) - 加载网络图片

    技术2022-05-19  29

    一、关键字

    Image. URL, URLConnection, BitmapFactory

    二、代码片段

    public Bitmap getRemoteImage(final URL aURL) { try { final URLConnection conn = aURL.openConnection(); conn.connect(); final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream()); final Bitmap bm = BitmapFactory.decodeStream(bis); bis.close(); return bm; } catch (IOException e) { Log.d("DEBUGTAG", "Oh noooz an error..."); } return null; } 


    最新回复(0)