Android HttpGet返回错误400某些电话的“错误请求”
我有一个类可以从我的应用程序的网站上获取JSON对象。 不幸的是,我遇到了一个问题,某些手机会收到错误400“错误请求”结果代码,而大多数手机都能很好地使用此代码 有谁知道这不适用于所有手机Android HttpGet返回错误400某些电话的“错误请求”,android,Android,我有一个类可以从我的应用程序的网站上获取JSON对象。 不幸的是,我遇到了一个问题,某些手机会收到错误400“错误请求”结果代码,而大多数手机都能很好地使用此代码 有谁知道这不适用于所有手机 public class MyAppJSON { private String params; public MyAppJSON(String params) { this.params = params; } public JSONObject read
public class MyAppJSON {
private String params;
public MyAppJSON(String params) {
this.params = params;
}
public JSONObject readJSON() {
JSONObject result = null;
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://www.myapp.com/json.php?action=" + this.params);
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
}
else {
Log.e(MyAppJSON.class.toString(), "Failed to download file");
}
result = new JSONObject(builder.toString());
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
return result;
}
}
那些设备可能运行安卓HC+?对不起,HC+是什么?我没有办法判断它们是否有,因为它们不是我的手机。他们是有这个bug的人的手机,其中一个好心地把他的手机借给我调试它。HC+=蜂窝状和以上。我想问的是,你是否使用Asynctask加载数据。1。是,该应用程序支持HC+。2.在这种情况下,http请求不在asynctask中,但应用程序中的其他请求在asynctask中。3.我的ICS手机工作正常。