【问题标题】:HttpSUrlConnection to create Bitmap gives SSL errorHttpSUrlConnection 创建位图给出 SSL 错误
【发布时间】:2011-03-26 10:06:05
【问题描述】:

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

我的问题是,如果 url 是 HTTP,我可以获取图像,但如果 url 是 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;                

【问题讨论】:

    标签: android bitmap imageview httpurlconnection


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      • 2014-12-21
      • 2012-06-24
      • 1970-01-01
      • 1970-01-01
      • 2018-05-20
      • 1970-01-01
      相关资源
      最近更新 更多