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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
gyubok
Posts: 448
Registered: ‎10-08-2009
My Carrier: Telus
Accepted Solution

Catching exit event

Hi, how would I catch when the user exits the app? I would like to do save some user setting before the app exits.

Please use plain text.
Developer
peter9477
Posts: 5,611
Registered: ‎12-08-2010
My Carrier: none

Re: Catching exit event

The proper way to do this is generally to set autoExit = false and process the manualExit() signal.

 

See https://developer.blackberry.com/cascades/reference/bb__application.html#manualexit

 


Peter Hansen -- (PlayBook and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
gyubok
Posts: 448
Registered: ‎10-08-2009
My Carrier: Telus

Re: Catching exit event

Thanks Peter,

 

As I am very new to dev, I have some basic questions.

 

I connected the event to a slot

 

QObject::connect(app, SIGNAL( manualExit() ), this, SLOT( onManualExit() ));

 

but inside onManualExit(), after I save everything, how do I actually quit the app?

Please use plain text.
Developer
peter9477
Posts: 5,611
Registered: ‎12-08-2010
My Carrier: none

Re: Catching exit event

When you're ready, just call Application.quit() https://developer.blackberry.com/cascades/reference/qcoreapplication.html#quit

Peter Hansen -- (PlayBook and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
gyubok
Posts: 448
Registered: ‎10-08-2009
My Carrier: Telus

Re: Catching exit event

Thanks Peter!

Please use plain text.
Developer
StevenKader
Posts: 614
Registered: ‎02-03-2010
My Carrier: Rogers

Re: Catching exit event

I am trying to  - 

 app.setAutoExit(false) ;

 

 but app is now not linking.  I get this error : 

undefined reference to symbol '_ZN2bb11Application11setAutoExitEb'

 

Anyone seen this.  Thanks.


Steven Kader at JaredCo
   Follow me on Twitter     BlackBerry Daily News

Feel free to press the like button to thank the user that helped you. Please mark posts as solved if you found a solution.
Please use plain text.
Developer
Zmey
Posts: 881
Registered: ‎12-18-2012

Re: Catching exit event

Add the following line to .pro file:
LIBS += -lbb
Please use plain text.
Developer
StevenKader
Posts: 614
Registered: ‎02-03-2010
My Carrier: Rogers

Re: Catching exit event


Zmey wrote:
Add the following line to .pro file:
LIBS += -lbb

Thanks...that worked.   I looked all over to see if I was missing another library (why can't the IDE add those automatically) but didn't find it.  Could you let me know where I should have seen it so I know for the next time.  Thanks.


Steven Kader at JaredCo
   Follow me on Twitter     BlackBerry Daily News

Feel free to press the like button to thank the user that helped you. Please mark posts as solved if you found a solution.
Please use plain text.
Developer
Zmey
Posts: 881
Registered: ‎12-18-2012

Re: Catching exit event

Sometimes it's mentioned in docs, but not always:

http://developer.blackberry.com/cascades/reference/bb__application.html

 

It's often possible to guess the library name. BB libs follow this convention:

#include <bb/cascades/...> the corresponding lib is libbbcascades.so which becomes -lbbcascades key.

#include <bb/device/...>: -lbbdevice

and so on.

The convention is not mandatory though so it might be hard to automate.

 

Grepping by function name in target's libraries folder can also give hints. If the function is declared in system headers then the implementation should also be present somewhere.

 

 

Please use plain text.
Developer
StevenKader
Posts: 614
Registered: ‎02-03-2010
My Carrier: Rogers

Re: Catching exit event

Got it....thanks.

Steven Kader at JaredCo
   Follow me on Twitter     BlackBerry Daily News

Feel free to press the like button to thank the user that helped you. Please mark posts as solved if you found a solution.
Please use plain text.