Code example for URLConnection

Methods: connectgetInputStream

0
    private Bitmap getImageBitmap(String url) {
        Bitmap bm = null;
        try { 
            URL aURL = new URL(url);
            URLConnection conn = aURL.openConnection();
            conn.connect();
            InputStream is = conn.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);
            bm = BitmapFactory.decodeStream(bis);
            bis.close();
            is.close();
        } catch (IOException e) {
            Log.e("GetImageBitmap Error", "Error getting bitmap", e);
        } 
        return bm;
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE