I'm following this answer from SO: Volley JsonObjectRequest Post request not working
I can't get the response data from the request.
I made the helper class in my android project and now try to do this:
RequestQueue requestQueue = Volley.newRequestQueue(this);
CustomRequest jsObjRequest = new CustomRequest(Method.POST, AppConfig.URL_LOGIN, datamap, this.RequestSuccessListener(), this.RequestErrorListener());
requestQueue.add(jsObjRequest);
This is my code of the requestSucessListener. The problem is I don't know how to pass the data object i receive from the response.
public void RequestSuccessListener(){
JSONObject jObj = new JSONObject();
//hideDialog();
try {
boolean error = jObj.getBoolean("error");
// Check for error node in json
if (!error) {
// user successfully logged in
// Create login session
session.setLogin(true);
// Now store the user in SQLite
String uid = jObj.getString("uid");
JSONObject user = jObj.getJSONObject("user");
String name = user.getString("name");
String email = user.getString("email");
String userid = user.getString("user_id");
// Inserting row in users table
// Launch main activity
//Intent intent = new Intent(LoginActivity.class,MainActivity.class);
//startActivity(intent);
//finish();
} else {
// Error in login. Get the error message
String errorMsg = jObj.getString("error_msg");
//Toast.makeText(getApplicationContext(),
// errorMsg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
// JSON error
e.printStackTrace();
//Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}