Skip to main content

limit login attempts

1 reply [Last post]
frankietook
Offline
Joined: 2010-08-15
Points: 0

hi how do i change this code to limit user attempts to 3?

public void validateUser(String name, String password) {
if (name.equals("admin") && password.equals("letmein")) {
display.setCurrent(list1);
} else {
tryAgain();
}
}
public void tryAgain() {
Alert error = new Alert("Login Incorrect", "Please try again", null, AlertType.ERROR);

Many thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sfitzjava
Offline
Joined: 2003-06-15
Points: 0

have a reference to the MIDlet instance
and add a static int to the class, like
private static int retries = 0;
private MIDlet midlet =

then add in your tryAgain

if( retries++ > 3)
{ midlet.notifyDestroyed();
midlet.destroyApp(true);
return;
}