NetworkDispatcher.run:未处理的异常java.lang.NullPointerException

时间:2017-07-28 07:06:28

标签: java android android-volley

我正在尝试运行下面的代码,使用volley库在我的Web服务器API上发送请求这是我的Make Web服务器命中功能。检查我的代码并告诉ma问题在哪里

    private void makeLoginRequest(String mEmail, String mPassword) {
        String urlJsonObj = Constants.WebUrls.baseUrl + Constants.BaseUrlPrefix.dgetLogin;
        showpDialog();
        Map<String, String> params = new HashMap<String, String>();
        params.put("email", mEmail);
        params.put("password", mPassword);
        params.put("signature", Utility.getmd5SignatureMAin(this));
        params.put("ts", Utility.getTimeStamp());
        params.put("client_id", Constants.clientID);
        params.put("platforms", Constants.plateForm);    AppController.getInstance().getSharedPrefrence().getPrefsKeyObjectId(this));
        params.put("parse_installation", AppController.getInstance().getSharedPrefrence().getdPrefsKeyInstallationId(this));


        CustomRequest jsObjRequest = new CustomRequest(Request.Method.POST, urlJsonObj, params, this.createRequestSuccessListener(), this.createRequestErrorListener());

    }


    public Response.Listener<JSONObject> createRequestSuccessListener() {
        Response.Listener<JSONObject> reponseListener;
        reponseListener = new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject jsonObject) {
                try {
                    if (jsonObject != null)
                        parseLogin(jsonObject);
                    else{
                        Log.e("ABC","DEF");
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                hidepDialog();


            }
        };
        return reponseListener;
    }

    Response.ErrorListener createRequestErrorListener() {
        Response.ErrorListener errorListener;
        errorListener = new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                volleyError.printStackTrace();
                hidepDialog();
                if (volleyError.networkResponse == null) {
                    if (volleyError.getClass().equals(TimeoutError.class)) {
                        // Show timeout error message
                        Toast.makeText(DLoginActivity.this,
                                "Oops. Timeout error!",
                                Toast.LENGTH_SHORT).show();

                    }
                    if ( volleyError.getClass().equals(NoConnectionError.class)) {
                    // Show timeout error message
                        Toast.makeText(DLoginActivity.this,
                        "No Internet Connection! Try Again Later",
                        Toast.LENGTH_SHORT).show();
                    }
                }
            }
        };
        return errorListener;
    }

但我收到以下错误:

  

E / Volley:[4189] NetworkDispatcher.run:未处理的异常   显示java.lang.NullPointerException       显示java.lang.NullPointerException           在libcore.net.UriCodec.encode(UriCodec.java:132)           在java.net.URLEncoder.encode(URLEncoder.java:57)           在com.android.volley.Request.encodeParameters(Request.java:449)           在com.android.volley.Request.getBody(Request.java:435)           在com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:236)           在com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:210)           在com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:106)           在com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)           在com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)

我不知道问题是什么。有人可以帮忙吗? 提前谢谢。

0 个答案:

没有答案