android java.net.ProtocolException: Connection already established

后端 未结 5 2036
南笙
南笙 2020-12-20 06:27
public static Bitmap getImage(String address) throws Exception {

    Bitmap imgmap = null;
    InputStream is = null;

    URL url = new URL(address);

    HttpURLC         


        
5条回答
  •  自闭症患者
    2020-12-20 07:11

    Thats because the function setRequestMethod() has to be called before the connection is made. Check this link

    http://developer.android.com/reference/java/net/HttpURLConnection.html#setRequestMethod(java.lang.String)

    So better call it before openConnection(). Or dont call it at all.

提交回复
热议问题