简体   繁体   中英

Android2.2 url connect exception

I have the following code for url connect, which throws an exception but the exception object is empty. how to connect to a url without any exception in android 2.2

HttpURLConnection urlConnection= null;
URL url = null;
    try
    {
     url = new URL(urlString.toString());
     urlConnection=(HttpURLConnection)url.openConnection();
     urlConnection.setRequestMethod("GET");
     urlConnection.setDoOutput(true);
     urlConnection.setDoInput(true);
     urlConnection.connect();
    }
    catch(Exception ex)
    {//ex is empty here}

I think a get-request does not like when output is enabled. In this case you should not set:

urlConnection.setDoOutput(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM