I’m trying to prompt the user for a Security PIN to allow them to access the app. The part that I’m having trouble with is prompting the user with an input dialog repeatedly if the pin entered is not correct.
Not sure how to “re-display” the dialog if the pin is incorrect.
Current Code:
bool correct = false;
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.SetTitle("Enter Security PIN");
EditText input = new EditText(this);
dialog.SetView(input);
dialog.SetPositiveButton("Login", (sender, args) =>
{
// check pin
string pin = prefs.GetString("pin", "0");
if (pin.CompareTo(input.Text) == 0)
{
correct = true;
}
else
{
// ??????? what to do here to redisplay dialog or prevent dismissal
}
});
dialog.SetNegativeButton("Exit", (sender, args) =>
{
this.Finish();
});
dialog.Show();
You should put your code into a function and call the function again in the
else.