이 코드를 사용하여 웹 서버에 HttpGet 요청을합니다. 에뮬레이터에서는 제대로 작동하지만 HTC Sense에서는 작동하지 않습니다. excecution은 http 요청을하지 않고 끝납니다. 어떤 생각?HttpClient가 실제 장치에서 작동하지 않습니다.
File f = new File(user.getPhotopath());
List<NameValuePair> reqparams = new LinkedList<NameValuePair>();
reqparams.add(new BasicNameValuePair("email", user.getEmail()));
reqparams.add(new BasicNameValuePair("pwd", user.getPassword()));
reqparams.add(new BasicNameValuePair("name", user.getScreenName()));
reqparams.add(new BasicNameValuePair("photo", f.getName()));
reqparams.add(new BasicNameValuePair("preference", user.getPrefs()));
reqparams.add(new BasicNameValuePair("bluetoothid", bid));
String urlstring = "http://www.mysite.com/me?"+ URLEncodedUtils.format(reqparams, "utf-8");
try {
URL url = new URL(urlstring);
URI myURI = null;
try {
myURI = url.toURI();
} catch (URISyntaxException e) {
e.printStackTrace();
}
HttpClient httpClient = new DefaultHttpClient();
HttpGet getMethod = new HttpGet(myURI);
HttpResponse webServerResponse = null;
HttpEntity httpEntity = null;
try {
webServerResponse = httpClient.execute(getMethod);
httpEntity = webServerResponse.getEntity();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (httpEntity != null) {
InputStream instream = httpEntity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
resultStr = sb.toString();
instream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
stacktrace를 표시하십시오. – Falmarri
실제로 스택 추적이 도움이 될뿐만 아니라 에뮬레이터가 프록시에서 작동하는지 여부도 도움이됩니다. – ndrix