I have written a simple code to check username and password entered by user and to act accordingly.
However when I run it I am getting error asking to FORCE QUIT
Please find the code:
Plz help
public void onClick(View v)
{
EditText username = (EditText)findViewById(R.id.EditTextUsername);
EditText password = (EditText)findViewById(R.id.EditTextPassword);
String CheckUsername = username.getText().toString();
String CheckPassword = password.getText().toString();
TextView status = (TextView)findViewById(R.id.TextViewErrorMsg);
if(CheckUsername=="")
status.setText("please enter username");
if(CheckPassword=="")
status.setText("please enter password");
if(CheckUsername=="xyz" && CheckPassword == "abcd") {
i = new Intent(LoginActivity.this, SignUpActivity.class);
startActivity(i);
} else {
i = new Intent(LoginActivity.this, AppLockActivity.class);
startActivity(i);
}
}
USE CheckUsername.equals(“”) and CheckUsername.equals(“abcd”) equals compares value of 2 objects where as = compares whether they are same object.