Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: How to prevent screen navigation using BlackBerry "back" key?

Check for Keypad.KEY_ESCAPE instead of Keypad.KEY_BACKSPACE




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Developer
ashishjmeshram
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers

Re: How to prevent screen navigation using BlackBerry "back" key?

Hi

 

I tried Keypad.KEY_ESCAPE instead of Keypad.KEY_BACKSPACE. The problem is still same.

 

The one thing I just noticed if I start my application and go to screen 1, screen 2, screen 3, screen 4,screen 5 and then on screen 6. On screen 6 when I click back it goes to screen 2 and not on screen 5. If I click on back key again it goes to screen 1 and then finally on blackberry desktop. 

 

Why is this happening?

Please use plain text.
Developer
ashishjmeshram
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers

Re: How to prevent screen navigation using BlackBerry "back" key?

No matter how many screen i navigate to , it always goes back to the same screen i.e. second screen of the application on click of back screen.

Please use plain text.
Developer
ashishjmeshram
Posts: 154
Registered: ‎01-08-2010
My Device: 8310 Rogers

Re: How to prevent screen navigation using BlackBerry "back" key?

Hi

 

The below code worked for me.

 

 

protected boolean keyChar(char c, int status, int time) {
	// TODO Auto-generated method stub
	if (c == Keypad.KEY_ESCAPE) {
		return true;
	}
	return super.keyChar(c, status, time);
}

 

 

Now when I click on back button it does not navigate to previous screens. It basically does not do anything.

 

User can go to desktop by clicking on red exit button and when starts app again he can go to the same screen which was there at time of exiting.

 

Can we not make it so that when the user clicks on the back button it behaves like red exit button and take user to the blackberry desktop instead of doing nothing?

 

 

Please use plain text.
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: How to prevent screen navigation using BlackBerry "back" key?

Look back at Arkady's post. You need to call Application.getApplication().requestBackground() before returning true when the escape key is pressed.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.