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

Native Development

Reply
Developer
gyubok
Posts: 520
Registered: ‎10-08-2009
My Device: Bold 9900
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.

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

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 -- (BB10 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!
Developer
gyubok
Posts: 520
Registered: ‎10-08-2009
My Device: Bold 9900

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?

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Catching exit event

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

Peter Hansen -- (BB10 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!
Developer
gyubok
Posts: 520
Registered: ‎10-08-2009
My Device: Bold 9900

Re: Catching exit event

Thanks Peter!

Developer
StevenKader
Posts: 644
Registered: ‎02-03-2010
My Device: Z10 LE

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    |     Mipixi.com :  Web App for Photo Sharing
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Catching exit event

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

Andrey Fidrya, @zmeyc on twitter
Developer
StevenKader
Posts: 644
Registered: ‎02-03-2010
My Device: Z10 LE

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    |     Mipixi.com :  Web App for Photo Sharing
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

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.

 

 


Andrey Fidrya, @zmeyc on twitter
Developer
StevenKader
Posts: 644
Registered: ‎02-03-2010
My Device: Z10 LE

Re: Catching exit event

Got it....thanks.

Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing