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
Ahmad89
Posts: 26
Registered: ‎10-24-2011
My Device: NoN
My Carrier: NoN

Preventing the user from leaving the app unless ....!

Hello again ^_^

 

Is there any way to prevent the user from leaving the application unless he do a task or enters a specific data, (i.e. password) ..

 

 

Thanks again

Please use plain text.
Developer
smiley
Posts: 1,419
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Preventing the user from leaving the app unless ....!

you can override all the hard keys and just return TRUE from the keyDown() method. When the user enters some data then you can call close() for the screen.

Please use plain text.
Developer
Ahmad89
Posts: 26
Registered: ‎10-24-2011
My Device: NoN
My Carrier: NoN

Re: Preventing the user from leaving the app unless ....!

How ?

Is there any doc or tutorial ?

Please use plain text.
Developer
jitendrasharma
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Preventing the user from leaving the app unless ....!

just override onClose() method in your screen, and in onClose() method check if the desired information has been entered or not, by some flag.

Please use plain text.
Developer
Ahmad89
Posts: 26
Registered: ‎10-24-2011
My Device: NoN
My Carrier: NoN

Re: Preventing the user from leaving the app unless ....!

Okay .. I've override the onClose() .. However, if I clicked on the menu button I can exit the program !

 

Is there any way to stop the user from getting away from my program unless s/he do what I tell him ?? *:Devil2:*

 

 

 

Please use plain text.
Developer
silver20
Posts: 455
Registered: ‎03-04-2011
My Device: Paper cup

Re: Preventing the user from leaving the app unless ....!

1. Override onClose,
2. Override deactivate(), add requestForeground()

There's a chance of deadlock in the unlikely case that another app is trying to do the same thing, so I'd slap a counter in deactivate() and break deadlock by yielding (skip the requestForeground) if there are more than 3 deactivations in a second.

You can help keep the display clean by adding suspendPainting(true) before the requestForeground in deactivate, and adding suspendPainting(false) in activate.
Please use plain text.
Contributor
bratbiswas
Posts: 10
Registered: ‎12-26-2011
My Device: 9000
My Carrier: Vodafone IN

Re: Preventing the user from leaving the app unless ....!

What is the user supposed to do if a call comes in and the password is yet to be entered? Shouldn't the phone app be given priority?

Please use plain text.
Developer
silver20
Posts: 455
Registered: ‎03-04-2011
My Device: Paper cup

Re: Preventing the user from leaving the app unless ....!

Think nothing can override the password screen, right?

 

Forgot about phone calls, a PhoneListener could be used to set a yield flag.  Also, onDown could be used to allow outgoing calls.  Could poll to see when the phone app is no longer the foreground app, then put the 'sticky' app right back on the foreground.

 

 

Please use plain text.