TNR
TNR

Reputation: 5869

Clearing Screen stack and disable back button in Blackberry Application

I have a requirement to restrict the user from pressing back button or disabling the back button in a screen. How should I get the Task done?

And Also on the same screen if user clicks the Ok button all the Screens from Home should get cleared and Home Screen should be displayed.

I got an answer here but it doesn't work. I am testing the app on Simulator 9550. Don't whether it is OS issue.

Thanks.

Upvotes: 1

Views: 570

Answers (1)

Nate
Nate

Reputation: 31045

In order to modify the behaviour when the user presses ESC / back, you simply override the keyChar() method in your Screen subclass(es):

protected boolean keyChar(char c, int status, int time) {
  if (c == Characters.ESCAPE) {
     // do nothing if ESC was pressed
     return true;
  } else {
     // accept the default behaviour for other keys
     return super.keyChar(c, status, time);
  }
}

In order to pop (remove) all screens except the app's home screen see this recent answer ... the one you linked to has a bug in it.

Upvotes: 4

Related Questions