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
New Contributor
Posts: 7
Registered: ‎05-31-2013
My Device: RIM & BlackBerry Z10
My Carrier: Airtel

Receive Power Off Event in Cascades

Hi All,

 

My application need to get notified when user switch off the device. Is there any bps event or SIGNALS related to Power Off Event. If anyone know any info about this, can you please share

 

 

Thanks

Chethan

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

Re: Receive Power Off Event in Cascades

Does this need to be when your app is not even running?

There's currently no trigger for that, so the best you could hope for with the current SDK is to detect it when your app is actually running.

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!
New Contributor
Posts: 7
Registered: ‎05-31-2013
My Device: RIM & BlackBerry Z10
My Carrier: Airtel

Re: Receive Power Off Event in Cascades

Hi,

 

I need this notification when my application is running. I tried with navigator bps events but my application won't get enough time to do the job.

 

Thanks

Chethan

 

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

Re: Receive Power Off Event in Cascades

What navigator BPS event did you find that could even signal this situation to your app?

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!
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Receive Power Off Event in Cascades

What are you trying to do? If the user has a device with a removable battery, they can always just yank it out and the device instantly loses power.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 1,046
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Receive Power Off Event in Cascades

This is always the problem with preventing data corruption, you can't ever be 100% certain you will have a chance to shut your app down cleanly. The best I can suggest without knowing exactly what the OP is trying to protect, is that you always store your fragile settings or data in a SQL database and use transaction processing to ensure they are never left in an undefined state.


PBernhardt wrote:

What are you trying to do? If the user has a device with a removable battery, they can always just yank it out and the device instantly loses power.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Receive Power Off Event in Cascades

And an alternative for beginners who are storing their data in simple files is always to write updates to a second file, then perform an atomic rename operation that overwrites the first, once the new file is fully flushed and closed. (Atomic here referring to the fact that with a rename operation on posix, the resulting file should always be either the old one or the new one, but never something odd like a blend of the two, or neither. See http://en.wikipedia.org/wiki/Rename_%28computing%29#Atomic_rename for more.)

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!