Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (myObjAsString == "WRONG_PASS_ERROR") { //USER_EXISTS_ERROR //WRONG_PASS_ERROR
- Toast.makeText(MainActivity.this, "Login Invalid", Toast.LENGTH_LONG).show();
- }
- String url = "http://someexample.com/signin.php";
- StringRequest postRequest = new StringRequest(Request.Method.POST, url,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- try {
- JSONObject jsonResponse = new JSONObject(response);
- String myObjAsString = jsonResponse.getString("type");
- if (myObjAsString == "WRONG_PASS_ERROR") { //USER_EXISTS_ERROR //WRONG_PASS_ERROR
- Toast.makeText(MainActivity.this, "Login Invalid", Toast.LENGTH_LONG).show();
- }
- mTV.setText(myObjAsString);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- error.printStackTrace();
- }
- }
- ) {
- @Override
- protected Map<String, String> getParams() {
- Map<String, String> params = new HashMap<>();
- // the POST parameters:
- params.put("email", "example@outlook.com");
- params.put("password", "*****");
- return params;
- }
- };
- Volley.newRequestQueue(this).add(postRequest);
- if (myObjAsString.equals("WRONG_PASS_ERROR")) // Change this condition
- {
- Toast.makeText(MainActivity.this, "Login Invalid", Toast.LENGTH_LONG).show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement