Guest User

Untitled

a guest
Nov 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. if (cd.isConnected()) {
  2.  
  3. final String username = etusuario.getText().toString();
  4. final String password = etpassword.getText().toString();
  5.  
  6. Response.Listener<String> respoListener = new Response.Listener<String>() {
  7.  
  8. @Override
  9. public void onResponse(String response) {
  10.  
  11. try {
  12. JSONObject jsonResponse = new JSONObject(response);
  13. boolean success = jsonResponse.getBoolean("success");
  14.  
  15. if (success) {
  16. String nombre = jsonResponse.getString("name");
  17. String apellido = jsonResponse.getString("surname");
  18. int brigada = jsonResponse.getInt("brigada");
  19.  
  20. Intent intent = new Intent(Logon.this, Opciones.class);
  21. intent.putExtra("nombre", nombre);
  22. intent.putExtra("apellido", apellido);
  23. intent.putExtra("usuario", username);
  24. intent.putExtra("brigada", brigada);
  25.  
  26. Logon.this.startActivity(intent);
  27. } else {
  28.  
  29. AlertDialog.Builder builder = new AlertDialog.Builder(Logon.this);
  30. builder.setMessage("Error en usuario o password")
  31. .setNegativeButton("Reintentar", null)
  32. .create().show();
  33. }
  34.  
  35. } catch (JSONException e) {
  36. Toast.makeText(getApplicationContext(), "Error JSON", Toast.LENGTH_SHORT).show();
  37. e.printStackTrace();
  38. }
  39. }
  40. };
  41.  
  42. LogonRequest logonRequest = new LogonRequest(username, password, respoListener);
  43. RequestQueue queue = Volley.newRequestQueue(Logon.this);
  44. queue.add(logonRequest);
  45.  
  46. private static final String LOGON_REQUEST_URL= Constant.RUTA_WEB + "appLogon.php";//"http://192.168.0.15/ConnBD_Android/appLogon.php";
  47. private Map<String,String> params;
  48. public LogonRequest(String username, String password, Response.Listener<String> listener){
  49. super(Method.POST, LOGON_REQUEST_URL, listener, null);
  50. params=new HashMap<>();
  51. params.put("username",username);
  52. params.put("password",password);
  53.  
  54.  
  55. }
  56.  
  57.  
  58. @Override
  59. public Map<String, String> getParams() {
  60. return params;
  61. }
  62.  
  63. //public static final String RUTA_WEB = "http://192.168.17.74/ConnBD_Android/";
  64. public static final String RUTA_WEB = "https://10.10.12.94/obras/CONNBD_ANDROID/";
Add Comment
Please, Sign In to add comment