我正在使用Volley库来获取JSON。我有我的Nexus 5,Nexus 7,运行Android 4.4.4,一切都很好。模拟器还在Android 4.2.2和4.4上获得JSON。当我试图使用运行Android 2.3.7的HTC Wildfire获取JSON时,它试图加载JSON但是然后退出。与运行Android 2.3的模拟器相同。
private void makeJsonObjectRequest() {
showpDialog();
final JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
urlJsonObj, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
extractJSONArray(response.getJSONArray("Accommodation"), "accommodation");
} catch (JSONException e) {
e.printStackTrace();
}
// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.notifyDataSetChanged();
hidepDialog();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(MainActivity.class.getSimpleName(), "Error: " + error.getMessage());
hidepDialog();
}
});
AppController.getInstance().addToRequestQueue(jsonObjReq);
}
com.android.volley.ParseError: org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject