当我在Android5.1上使用Volley Library时,一切正常。但
当我在6.0上运行时,我得到了不支持的操作异常。可能的原因是什么?
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.e(TAG, response.toString());
try {
String apiNum = response.getString("apiNum");
switch (apiNum){
case "1":
Log.e(TAG, "CASE 1");
break;
case "2":
Log.e(TAG, "CASE 2");
prefs.edit().putString("id", id.getText().toString())
.putString("secret", password.getText().toString()).commit();
listener.onRegister("success");
break;
case "-1":
Log.e(TAG, "CASE -1");
listener.onRegister("not_exists");
break;
default:
listener.onRegister("error");
Log.e(TAG, "DEFAULT");
break;
}
} catch (JSONException e) {
showAlert(getActivity(),
"JSONException,"+"MEggase="+e.getMessage()+"Cause:"+e.getCause());
e.printStackTrace();
}
pDialog.hide();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error: " + error.getMessage());
showAlert(getActivity(), "VolleyError,
"+"MEggase="+error.getMessage()+"Cause:"+error.getCause());
pDialog.hide();
}
} );
// Adding request to request queue
try{
AppController.getInstance().addToRequestQueue(jsonObjReq, tag_json_arry);
} catch (Exception e){
showAlert(getActivity(), "AddToRequestQueue Error");
}发布于 2017-03-22 15:07:52
解决了,问题出在权限上。当我添加了权限请求后,应用程序就可以正常工作了。
https://stackoverflow.com/questions/42920700
复制相似问题