首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Volley错误-发出json请求时发生UnsupportedOperationException

Volley错误-发出json请求时发生UnsupportedOperationException
EN

Stack Overflow用户
提问于 2017-03-21 15:25:11
回答 1查看 70关注 0票数 0

当我在Android5.1上使用Volley Library时,一切正常。但

当我在6.0上运行时,我得到了不支持的操作异常。可能的原因是什么?

代码语言:javascript
运行
复制
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");

        }
EN

回答 1

Stack Overflow用户

发布于 2017-03-22 15:07:52

解决了,问题出在权限上。当我添加了权限请求后,应用程序就可以正常工作了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42920700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档