Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. if (myObjAsString == "WRONG_PASS_ERROR") { //USER_EXISTS_ERROR //WRONG_PASS_ERROR
  2.  
  3. Toast.makeText(MainActivity.this, "Login Invalid", Toast.LENGTH_LONG).show();
  4. }
  5.  
  6. String url = "http://someexample.com/signin.php";
  7. StringRequest postRequest = new StringRequest(Request.Method.POST, url,
  8. new Response.Listener<String>() {
  9. @Override
  10. public void onResponse(String response) {
  11. try {
  12.  
  13.  
  14. JSONObject jsonResponse = new JSONObject(response);
  15. String myObjAsString = jsonResponse.getString("type");
  16.  
  17. if (myObjAsString == "WRONG_PASS_ERROR") { //USER_EXISTS_ERROR //WRONG_PASS_ERROR
  18.  
  19. Toast.makeText(MainActivity.this, "Login Invalid", Toast.LENGTH_LONG).show();
  20. }
  21.  
  22. mTV.setText(myObjAsString);
  23.  
  24. } catch (JSONException e) {
  25. e.printStackTrace();
  26. }
  27. }
  28. },
  29. new Response.ErrorListener() {
  30. @Override
  31. public void onErrorResponse(VolleyError error) {
  32. error.printStackTrace();
  33. }
  34. }
  35. ) {
  36. @Override
  37. protected Map<String, String> getParams() {
  38. Map<String, String> params = new HashMap<>();
  39. // the POST parameters:
  40. params.put("email", "example@outlook.com");
  41. params.put("password", "*****");
  42. return params;
  43. }
  44. };
  45. Volley.newRequestQueue(this).add(postRequest);
  46.  
  47. if (myObjAsString.equals("WRONG_PASS_ERROR")) // Change this condition
  48. {
  49. Toast.makeText(MainActivity.this, "Login Invalid", Toast.LENGTH_LONG).show();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement