即使我填写了正确的引脚,Toast仍然拒绝接入访问.
我需要将用户锁定在自助服务终端模式应用中,只有使用正确的引脚,他们才能访问设置和退出选项.
public void onClick(View v) {
AlertDialog.Builder alert = new AlertDialog.Builder(FullscreenActivity.this);
alert.setTitle("PIN:");
//alert.setMessage("Message");
final EditText pinEntry = new EditText(FullscreenActivity.this);
alert.setView(pinEntry);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String pin = pinEntry.getText().toString().trim();
String secret = "0000";
if (pin == secret){
Toast.makeText(getApplicationContext(),"Access Approved", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(getApplicationContext(),"Access Denied", Toast.LENGTH_SHORT).show();
}
Toast.makeText(getApplicationContext(),pin, Toast.LENGTH_SHORT).show();
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.show();
}
});
Run Code Online (Sandbox Code Playgroud)