我在Samsung S5中发现使用HTTPURLCONNECTION的问题可能是我做错了但是如果有人有想法请指导我。
这是我的代码:
URL urls = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urls.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("x-os-application-token", Constants.APPLICATION_TOKEN);
connection.setConnectTimeout(900000);
connection.setReadTimeout(150000);
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
DataOutputStream wr = new DataOutputStream(
connection.getOutputStream());
wr.writeBytes(json);
wr.flush();
wr.close();
int responseCode = connection.getResponseCode();
现在使用此代码,如果我手动上网断开(WI_FI OFF),那么其他设备(例如Nexus 5和三星Galaxy Note 3)会立即给我回复,但在三星S5中它会在 connection.setReadTimeout(150000)之后回复我 ??? 2.5分钟