Android アプリへのログイン ページを作成しようとしています。私は2つの編集ビューとボタンを持っています。ログインに静的ユーザー資格情報を使用しています。アプリを実行し、正しいユーザー名とパスワードでログインしようとすると、資格情報が正しくないというメッセージが表示されます。
これが私のコードです。これは非常に単純なコードです
public void sendMessage(View view) {
EditText user_name = (EditText)findViewById(R.id.txt_username);
EditText password =(EditText)findViewById(R.id.txt_password);
if(user_name.getText().toString()=="rotanet" && password.getText().toString()=="rotanet"){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
TextView lbl_error = (TextView)findViewById(R.id.lbl_error);
lbl_error.setText("");
}
else{
TextView lbl_error = (TextView)findViewById(R.id.lbl_error);
lbl_error.setText("wrong credentials!");
}
}