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

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

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
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

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
zahirw
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900

Re: app,exit() doesnt exit app

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

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
zahirw
Posts: 134
Registered: ‎04-15-2012
My Device: Bold 9900

Re: app,exit() doesnt exit app

Thanks Pawan!
Developer
pankajace12
Posts: 206
Registered: ‎04-30-2011
My Device: BlackBerry Z10

Re: app,exit() doesnt exit app

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

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

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?