I am trying to run below code to send request on my web server API using volley library this is my Make web server hit functions. check my code and tell ma where is the problem
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;
}
But I am getting following error:
E/Volley: [4189] NetworkDispatcher.run: Unhandled exception java.lang.NullPointerException java.lang.NullPointerException at libcore.net.UriCodec.encode(UriCodec.java:132) at java.net.URLEncoder.encode(URLEncoder.java:57) at com.android.volley.Request.encodeParameters(Request.java:449) at com.android.volley.Request.getBody(Request.java:435) at com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:236) at com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:210) at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:106) at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93) at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)
I have no idea what is to problem. Can anyone help? Thanks in advance.