Hallo,

After upgrade to android 2.3.5 and 2.3.6, the code for android
HttpURLConnection class: urlconn.connect(), urlconn.getOutputStream()
and urlconn.getInputStream() becomes very slow (each command takes
more than 5 second, under version 2.3.2 or 2.2 it just take less than
1 sec).
Does any one has the same situation?

My codes looks like this:

getUrl = new URL(url);
urlConn = (HttpURLConnection) getUrl.openConnection();

urlConn.setUseCaches(false);
urlConn.setRequestMethod(httpMethod.name());
urlConn.setConnectTimeout(HTTP_CONNECT_TIMEOUT);
urlConn.setReadTimeout(HTTP_READ_TIMEOUT);
urlConn.setDoInput(true);
if (requestBody != null)
        urlConn.setFixedLengthStreamingMode(requestBody.length());
if (!(httpMethod == HttpMethod.GET))
        urlConn.setDoOutput(true);

urlConn.connect();

if (requestBody != null) {
        osw = new OutputStreamWriter(urlConn.getOutputStream());
        osw.write(requestBody);
        osw.flush();
}

in = urlConn.getInputStream();
buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[256];
while ((nRead = in.read(data, 0, data.length)) != -1) {
        buffer.write(data, 0, nRead);
}
buffer.flush();
responseBody = buffer.toByteArray();
responseCode = urlConn.getResponseCode();

Regards,
Zheng

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to