I have the following Android program code. It does not work even I input "admin", the correct answer. Then I Toast my input which exactly the same as the == "admin". But it still does not work !!! Is there any trick ? Please help !! Many thanks !!
EditText etPassword =(EditText) findViewById(R.id.etPassword);
String t_etPassword =etPassword.getText().toString();
// display the t_etPassword for checking since the "if" does not work
Toast.makeText(getApplicationContext(), "<<" +t_etPassword +">>", Toast.LENGTH_SHORT).show();
if (t_etPassword == "admin") {
Intent intent = new Intent(getBaseContext(), ContactListActivity.class);
startActivity(intent);
} else {
Toast.makeText(getApplicationContext(), "Un-Authorised Access !!", Toast.LENGTH_SHORT).sho();
}
}
});