public void onClick(View view) { try { Context context = getApplicationContext(); // get username and role coming from previous page String userName = this.getIntent().getStringExtra("name"); String role = this.getIntent().getStringExtra("role"); String password = ((EditText) findViewById(R.id.pswd)).getText().toString(); String confirmPassword = ((EditText) findViewById(R.id.confpswd)).getText().toString(); if ((password.length() == 0) || (confirmPassword.length() == 0)) { Toast.makeText( getApplicationContext(), "password or confirm password can not be Empty", Toast.LENGTH_SHORT) .show(); Log.i("password and conf password", password + ":::" + confirmPassword); return; } if (password.equals(confirmPassword)) { if (!confirmPassword.equalsIgnoreCase("password")) { // do our job here ServiceInvoker.changePassword(session.getToken(), confirmPassword); // password is changed so new token need tobe set session.setAuthenticationToken(userName, confirmPassword); // DO Navigation Here if (role.equals("ROLE_ADMIN")) { Intent intent = new Intent(context, AdminHomePage.class); intent.putExtra("name", userName); startActivity(intent); } else if (role.equals("ROLE_MANAGER")) { Intent intent = new Intent(context, ManagerHomePage.class); intent.putExtra("name", userName); startActivity(intent); } else if (role.equals("ROLE_STAFF")) { Intent intent = new Intent(context, StaffHomePage.class); intent.putExtra("name", userName); startActivity(intent); } else { Intent intent = new Intent(context, LoginPage.class); startActivity(intent); Toast.makeText(getApplicationContext(), "User Not Found", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText( getApplicationContext(), "password can not be password", Toast.LENGTH_SHORT) .show(); } } else { Toast.makeText(getApplicationContext(), "password mismatched", Toast.LENGTH_SHORT).show(); } } catch (Exception ee) { Log.i("Error In Reset Password", ee.getMessage()); } }