My code...
public class Login extends AppCompatActivity {
DBHelper mydb;
RequestQueue requestQueue;
String em,li;
String activationurl="xxx";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button submit=(Button)findViewById(R.id.button);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText email=(EditText)findViewById(R.id.editText12) ;
EditText license=(EditText)findViewById(R.id.editText13);
em=email.getText().toString();
li=license.getText().toString();
new Asyncimg().execute();
}
});
}
class Asyncimg extends AsyncTask<Object, Object, JSONObject>
{
protected JSONObject doInBackground(Object... arg0) {
JSONObject jsonObj = new JSONObject();
try {
jsonObj.put("email",em);
jsonObj.put("licensekey",li);
Log.d("object",jsonObj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
return jsonObj;
}
protected void onPostExecute(JSONObject result) {
Log.d("return",result.toString());
JsonArrayRequest request = new JsonArrayRequest(Request.Method.POST,
activationurl, result,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
JSONObject store = response.getJSONObject(0);
Log.d("responce",response.toString());
mydb.insertdoc(store.getInt("doctor_id"),store.getString("doctor_name"),store.getString("doctor_dob"),store.getString("doctor_gender"),store.getString("doctor_contact_no"),store.getString("doctor_email"),store.getString("doctor_license_key"));
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
public String getBodyContentType() {
return "application/json";
}
};
request.setRetryPolicy(new DefaultRetryPolicy(50000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
requestQueue.add(request);
}
}
}
Error...
java.lang.NullPointerException: Attempt to invoke virtual method 'com.android.volley.Request com.android.volley.RequestQueue.add(com.android.volley.Request)' on a null object reference
How can i solve this issue... Another activity with volleey working perfectly... How can i resolve this issue... I need to send this jason to server... How can i do it... I ve tried adding appController in manifest but no successs