HttpSUrlConnection创建Bitmap会产生SSL错误

时间:2011-03-26 10:06:06

标签: android bitmap imageview httpurlconnection

我正在尝试从网络中获取图像并将其显示在imageview

我的问题是,如果网址是HTTP,我可以获取图片,但如果网址是HTTPS则无法获取

我使用以下代码: -

    Bitmap bitmap = null;
    InputStream in = null;        
    try {

          URL url = new URL(URL);   
          URLConnection conn = url.openConnection();
        //  HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
          conn.connect();
          in = conn.getInputStream();
        bitmap = BitmapFactory.decodeStream(in);
        in.close();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    return bitmap;                

1 个答案:

答案 0 :(得分:0)

我猜你需要与https服务器进行一些握手,因为它是安全协议。您可以在此处找到解决方案:Https Connection Android