I'm sending post request for login user on server through volley string request. It works perfectly but the problem is that after sending request server returns me two responses one is success in which token id is given and the other one is failure in which unauthorized user is toast. Im getting the response perfectly but can use check to differentiate these responses. Kindly someone helps me Im very thakful to you.
I'm trying many times but can't get the exact solution.
RequestQueue queue = Volley.newRequestQueue(this);
String url =LOGIN_URL;
final StringRequest strRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>()
{
@Override
public void onResponse(String response)
{
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_SHORT).show();
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
Toast.makeText(getApplicationContext(), error.toString(), Toast.LENGTH_SHORT).show();
}
})
{
@Override
protected Map<String, String> getParams()
{
Map<String, String> params = new HashMap<String, String>();
params.put("grant_type", grant_type);
params.put("client_id", client_id);
params.put("client_secret", client_secret);
params.put("username", email);
params.put("password", password);
return params;
}
};
queue.add(strRequest);