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

Web and WebWorks Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Trusted Contributor
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900
My Carrier: Vodafone

app,exit() doesnt exit app

I'm trapping the back button function on my app, throwing up and alert and exiting the app if the user confirms.

 

On the device, the alert shows up when I hit back however, confirming doesnt close the app.

 

This is my code.

 

blackberry.system.event has been enabled in config.xml

 

blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, function(){
if (confirm("Are you sure you want to exit this application?"))
{
blackberry.app.event.onExit(null);
blackberry.app.exit();
}
});

 

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: app,exit() doesnt exit app

Use this code, will be helpful to you.

public boolean keyChar(char key, int status, int time)
{
boolean retval = false;
if(key == Characters.ESCAPE)
{
retval = true;
int response = Dialog.ask(Dialog.D_YES_NO, "Do you really want exit??");
if(response == Dialog.YES)
System.exit(0);
}
else if(key == Characters.ENTER)
{
navigationClick(status, time);
return true;
}
else
{
retval = super.keyChar(key,status,time);
}
return retval;
}

Trusted Contributor
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: app,exit() doesnt exit app

Pawan, have you tested this code?
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: app,exit() doesnt exit app

yes, i have test this code.

 

in this function, if you do press back button, then a dialog box will pop up. and that will give you two option.

 

1) yes    2) No

 

if you press yes, then app is close.

 

if no then current will screen will be continue.

Trusted Contributor
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: app,exit() doesnt exit app

Thanks Pawan!
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: app,exit() doesnt exit app

And, this is working fine my smart phone simulator.......

Highlighted
Trusted Contributor
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: app,exit() doesnt exit app

Tried this, seems to use classes. Wasn't able to successfully implement it.

Doesnt the api documentation support exit?