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
New Developer
Posts: 10
Registered: ‎09-15-2010
My Device: Not Specified
Accepted Solution

How to put in standby an application when lose focus (incoming call, red button pressed, etc)

Good Morning.

I'm developing a game for bb 9000 (4.6.0) and I would like to stop the game when the user switches to another application (e.g. pressing the red button or answering to a phone call)

I'm using threads to make the game working and there are some static variables I use to test if stop or not the game.

For example, if I press "p" I can pause the game.

But... I can't find the way to put in pause the game if a call is arriving or if the user presses the red button.

Generally if there is an event that put in background the application, I'd like to pause the game.

 

Do you know how to help me?

 

Thanks in advance

Highlighted
Developer
Posts: 1,452
Registered: ‎11-06-2009
My Device: Torch 9810
My Carrier: WiFi

Re: How to put in standby an application when lose focus (incoming call, red button pressed, etc)

You can check following methods

 

Screen.onObscured()
Screen.onUiEngineAttached(boolean) 
Field.onVisibilityChange(boolean)

 

It is up to you which one is most appropriate for your app, you can place a code to pause the game inside the method you choose

 



"When you become a level 3 developer, you learn to communicate over the ether. I'm told that level 5 developers are ascend into a higher level of existence beyond the physical realm." gord888 @ crackberry
New Developer
Posts: 10
Registered: ‎09-15-2010
My Device: Not Specified

Re: How to put in standby an application when lose focus (incoming call, red button pressed, etc)

Many Thanks.
I will use Screen.onExposed and onObscured.

Thks