我将数据发布到服务器,在调试时我在此行收到以下错误。并且无法呼叫服务器。
网络电话。我使用的是sql server版本2014,网站服务的网址是localhost:8081/api/login/signup
。
StringRequest strReq = new StringRequest(Request.Method.POST, Constants.SIGN_UP,new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Snackbar.make(mainlayout, response.toString(), Snackbar.LENGTH_LONG).show();
Log.e("Responce from server", response);
avi.hide();
if(!response.contains("User")) {
spEdit.putString(getString(R.string.uaccount), response);
spEdit.commit();
Intent intent = new Intent(SignUp.this, Products.class);
intent.putExtra(getString(R.string.uemail), Email_Address);
intent.putExtra(getString(R.string.uphone), Phone_Number);
intent.putExtra(getString(R.string.upass), Password);
startActivity(intent);
finish();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
avi.hide();
Log.e("Volley Error", error.toString());
if(error.toString().contains("NoConnectionError")) {
Snackbar.make(mainlayout, "Internet Not Available!", Snackbar.LENGTH_LONG).show();
}else{
Snackbar.make(mainlayout, "Webservice not responding!", Snackbar.LENGTH_LONG).show();
}
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> data = new HashMap<String, String>();
String name[] = Name.split(" ");
String first = "", last = "";
boolean firstb = true;
for (int i = 0; i < name.length; i++) {
if (firstb) {
first += name[i];
firstb = false;
} else {
if (i == name.length - 1) {
last = name[i];
} else {
first += " ";
first += name[i];
}
}
}
data.put("FirstName", first);
data.put("LastName", last);
data.put("LoginName", Login_Name);
data.put("PrimaryEmail", Email_Address);
data.put("PrimaryPasscode", Encrypted_Password);
data.put("PhoneNumber", Phone_Number);
data.put("MobileVerificationCode", smsCode);
data.put("AccountType", UserType);
return data;
}
};
AppController.getInstance().addToRequestQueue(strReq, REQ_TAG);
}
错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: market.enxo.com.marketstore, PID: 3202
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at com.android.volley.Request.<init>(Request.java:136)
at com.android.volley.toolbox.StringRequest.<init>(StringRequest.java:43)
at market.enxo.com.marketstore.SignUp$8.<init>(SignUp.java:361)
at market.enxo.com.marketstore.SignUp.signUpWS(SignUp.java:332)
at market.enxo.com.marketstore.SignUp$4.onClick(SignUp.java:297)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)