login.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if( username_text.getText().toString() == "admin" &&
pass_text.getText().toString() == "password"){
startActivityForResult(i, ACTIVITY_CREATE);
}else{
Toast.makeText(gps_gui.this, "Your username or password is not correct! Please, insert again",
Toast.LENGTH_SHORT).show();
clearEditText();
}
}
});
I’m try to check it, I found it not go to if condition.
When using java, you must compare Strings using the String.equals(String) method. The == comparison checks to see if the String object values are equal, which undoubtedly they are not. Try to change you example to :
Its also smart to put the static string first, in case the string value of the value being checked is null.