EditText un = (EditText) findViewById(R.id.username1);
EditText pw = (EditText) findViewById(R.id.password1);
String u = un.getText().toString();
String p = pw.getText().toString();
String myUser = "user1";
String myPass = "pass1";
public void onClickL (View view){
if ( (u == myUser) && (p == myPass)) /////// phone should alarm
else //////error
}
Asked
Active
Viewed 43 times
-1

wogsland
- 9,106
- 19
- 57
- 93

Prasad Maghade
- 1
- 1
-
Looks great, what's wrong? – Seano666 Feb 18 '16 at 17:37
-
http://stackoverflow.com/questions/3289038/play-audio-file-from-the-assets-directory – Matt Wolfe Feb 18 '16 at 17:39
-
You can use soundpool to play some short sound – Ricci Feb 18 '16 at 17:50
1 Answers
0
Change this line
if ( (u == myUser) && (p == myPass))
to
if (u.equals(myUser) && p.equals(myPass))
Full code
EditText un = (EditText) findViewById(R.id.username1);
EditText pw = (EditText) findViewById(R.id.password1);
String u = un.getText().toString();
String p = pw.getText().toString();
String myUser = "user1";
String myPass = "pass1";
public void onClickL (View view){
if (u.equals(myUser) && p.equals(myPass)){ /////// phone should alarm
else //////error
}

Inducesmile
- 2,475
- 1
- 17
- 19