안드로이드 개발 질문/답변
(글 수 45,052)
try {
URL url = new URL(path);
conn = (HttpURLConnection)url.openConnection();
if (conn != null){
conn.setConnectTimeout(10000);
conn.setUseCaches(false);
int nCode = conn.getResponseCode(); <-- 이부분에서 -1 이 리턴 됩니다.
if (nCode == HttpURLConnection.HTTP_OK) {
생략..
} // if
conn.disconnect();
} // if
} catch (Exception e) {
try {
if (conn != null) conn.disconnect();
} catch (Exception e2) {
}
throw e;
}
int nCode = conn.getResponseCode();
에뮬에서는 문제없이 HttpURLConnection.HTTP_OK 를 리턴합니다.
그런데.. 폰에 넣고 디버깅 해보면 -1이 리턴 됩니다.
뭐가 문제일까요??
고수님들의 의견 바랍니다. T.T
URL url = new URL(path);
conn = (HttpURLConnection)url.openConnection();
if (conn != null){
conn.setConnectTimeout(10000);
conn.setUseCaches(false);
int nCode = conn.getResponseCode(); <-- 이부분에서 -1 이 리턴 됩니다.
if (nCode == HttpURLConnection.HTTP_OK) {
생략..
} // if
conn.disconnect();
} // if
} catch (Exception e) {
try {
if (conn != null) conn.disconnect();
} catch (Exception e2) {
}
throw e;
}
int nCode = conn.getResponseCode();
에뮬에서는 문제없이 HttpURLConnection.HTTP_OK 를 리턴합니다.
그런데.. 폰에 넣고 디버깅 해보면 -1이 리턴 됩니다.
뭐가 문제일까요??
고수님들의 의견 바랍니다. T.T



