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
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Distinguish between user-requested exit and system-triggered exit?

Does anyone know of a way (indirect or otherwise) to distinguish between an exit requested by a user (by swiping up then hitting the X widget) and an exit triggered by the system (e.g. when an app is the 8th app and the user launches another, or on system shutdown from low battery)?

 

Without adding an in-app Quit button, I'd like to be able to detect when it was a user choice to exit the app.

 

(I doubt it's possible but I'm hoping I overlooked something anyway.)


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
Posts: 1,626
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Distinguish between user-requested exit and system-triggered exit?

interesting question

 

perhaps Simon Hain has an idea ?

he already figured out all the different states

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Distinguish between user-requested exit and system-triggered exit?

ekke, your comment gives me one idea I didn't already have (since it made me think our investigations into app and window states).

I could watch for the thumbnail state and, if the app is closed within about two seconds following that, I can be pretty confident it's a deliberate user action.

Not fool-proof by any means, but it might be useful as a rudimentary approach if no better way can be found.

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
Posts: 1,626
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Distinguish between user-requested exit and system-triggered exit?

perhaps also watching for low battery ?

 

BTW: happens so many time: only discussing a topic with another dev to find solutions or workarounds

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 16,517
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Distinguish between user-requested exit and system-triggered exit?

using thumbnail or process state would be a workaround.

You can also investigate this:
https://developer.blackberry.com/native/reference/cascades/bb__application.html?f=app#function-manua...
but i guess it does not discern between a user-driven and a system-driven exit.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
BlackBerry Development Advisor
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10

Re: Distinguish between user-requested exit and system-triggered exit?

Hi peter9477,

 

By setting the autoExit flag of the Application class to false you can make your application take control of the application exit irrespective of what triggered the existing.

 

You might find the manualExit section of this blog post useful for what you are trying to achieve.

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker