Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (cd.isConnected()) {
- final String username = etusuario.getText().toString();
- final String password = etpassword.getText().toString();
- Response.Listener<String> respoListener = new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- try {
- JSONObject jsonResponse = new JSONObject(response);
- boolean success = jsonResponse.getBoolean("success");
- if (success) {
- String nombre = jsonResponse.getString("name");
- String apellido = jsonResponse.getString("surname");
- int brigada = jsonResponse.getInt("brigada");
- Intent intent = new Intent(Logon.this, Opciones.class);
- intent.putExtra("nombre", nombre);
- intent.putExtra("apellido", apellido);
- intent.putExtra("usuario", username);
- intent.putExtra("brigada", brigada);
- Logon.this.startActivity(intent);
- } else {
- AlertDialog.Builder builder = new AlertDialog.Builder(Logon.this);
- builder.setMessage("Error en usuario o password")
- .setNegativeButton("Reintentar", null)
- .create().show();
- }
- } catch (JSONException e) {
- Toast.makeText(getApplicationContext(), "Error JSON", Toast.LENGTH_SHORT).show();
- e.printStackTrace();
- }
- }
- };
- LogonRequest logonRequest = new LogonRequest(username, password, respoListener);
- RequestQueue queue = Volley.newRequestQueue(Logon.this);
- queue.add(logonRequest);
- private static final String LOGON_REQUEST_URL= Constant.RUTA_WEB + "appLogon.php";//"http://192.168.0.15/ConnBD_Android/appLogon.php";
- private Map<String,String> params;
- public LogonRequest(String username, String password, Response.Listener<String> listener){
- super(Method.POST, LOGON_REQUEST_URL, listener, null);
- params=new HashMap<>();
- params.put("username",username);
- params.put("password",password);
- }
- @Override
- public Map<String, String> getParams() {
- return params;
- }
- //public static final String RUTA_WEB = "http://192.168.17.74/ConnBD_Android/";
- public static final String RUTA_WEB = "https://10.10.12.94/obras/CONNBD_ANDROID/";
Add Comment
Please, Sign In to add comment