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: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers
Accepted Solution

Catch and act on user closing tile

Is there another way to catch when the user hits the X to close my app tile.  If I catch it on the app exit then there is no way to stop the exit since the tile is already closed.  I think there may be some navigator events to watch but not sure.  Anyone been able to do this?  Thanks.


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 207
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon

Re: Catch and act on user closing tile

I could be wrong but I think that would be against BlackBerry app design principles. Preventing a user from closing your app? Why would you want to do that?
_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Developer
Posts: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Catch and act on user closing tile

The app needs to run in the backgroud....so I need to put up a dialog box to warn them about closing the app.  They have a choice to continue to close or cancel to keep it open.  Just having trouble catching the close before the app is actually exiting.


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
Posts: 207
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon

Re: Catch and act on user closing tile

Try this:

 

// 1. Start the library
 bps_initialize();

 // 4. Listen for events
 for (;;) {
   // get an event
    bps_event_t *event;
    bps_get_event(&event, -1); // blocking

    // handle the event
    handle_event(&event);
 }

 bps_shutdown();

 and have the bps_event_t the event type for closing the navigator, which can be found in this general section 

 

https://developer.blackberry.com/native/reference/bb10/com.qnx.doc.bps.lib_ref/com.qnx.doc.bps.lib_r...

 

But I don't know if a dialog box would be able to be displayed still.  

 

Hopefully that helps but I think that if your app is running something and the user closes it, then they obviously didn't want to keep whatever process running and they just suffer the concequences.  Because lets be honest, to hit that tiny X button, they meant to hit it, not like an accidental kind of thing could happen very often.  But your call, see if the above helps.

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Catch and act on user closing tile

Steven, you're looking for this, I think: https://developer.blackberry.com/cascades/reference/bb__application.html#function-setcloseprompt-tit...


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: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: Catch and act on user closing tile

That's it.....never saw that one.  Thanks for pointing it out.   I'll have to dig thru all of the APis to see what else is hidden away.  


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