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
New Developer
success_anil
Posts: 30
Registered: ‎10-16-2009
My Device: Not Specified
Accepted Solution

How to exit from a Widget Application

Hi

I read about

Application Event Object

 

In BB widget api docs. I tried exiting from the widget by trapping the exit  in between using javascript functions. I used the sample script code written in the doc.

 

 

<script type="text/javascript">

function trapForApplicationExit()
{
blackberry.app.event.onExit(handleExit);
}


function handleExit()
{
var answer = confirm("Leave this application?");
if (answer)
blackberry.app.exit();
}
</script>

 I 've added the feature element in config.xml. 

 

  But nothing happens when i exit from application using the exit button on simulator.

 

 

 

 

Kleward Consulting Pvt Ltd
Exceptional People : Exceptional Talent
Developer
davidmccormack
Posts: 168
Registered: ‎11-01-2008
My Device: Galaxy S II

Re: How to exit from a Widget Application

Have you called trapForApplicationExit() from somewhere?? Just putting that sample code in your script won't magically make it run :smileyhappy: You need to call trapForApplicationExit() - probably from whatever function you've written to handle the document load.

 

Note that you need to enable two features for the above script to work - blackberry.app and blackberry.app.event. Remember too, as I've just said in your other thread, that if the page/script is being served from a remote server (instead of being local to the widget) you need to have the feature elements contained within the relevant access element. 

New Member
louenas
Posts: 1
Registered: ‎12-10-2010
My Device: Not Specified

Re: How to exit from a Widget Application

I used this work around. it worked on the Torch but you need to click on close twice. good luck.

 

blackberry.app.event.onExit(handleExit);  

function handleExit(){
       var answer = confirm("Leave the application?");
       if (answer){ 

                       blackberry.app.event.onExit(null);

                       blackberry.app.exit(); 

       };
}

Contributor
Solas_alok
Posts: 23
Registered: ‎12-27-2012
My Device: BB10

Re: How to exit from a Widget Application

Tried above code also added feature is config.xml. Still not working on BB10.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800

Re: How to exit from a Widget Application

blackberry.app.exit() is working for me.

make sure blackberry.app exists.
@nukulb
Contributor
Solas_alok
Posts: 23
Registered: ‎12-27-2012
My Device: BB10

Re: How to exit from a Widget Application

blackberry.app...exits..still not working
Retired
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10

Re: How to exit from a Widget Application

More information and code available here: https://github.com/blackberry/BB10-WebWorks-Framework/issues/393

@erikjohnzon
erjohnson@blackberry.com