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

Java Development

Reply
Highlighted
Contributor
Posts: 22
Registered: ‎01-12-2011
My Device: Not Specified
Accepted Solution

Block on device power off

I have implemented a systemlistener that gets notified when the device is powering off. What I want to know is if there is a method to request more time from the system before it shuts down? The listener's call doesn't cause any blocking of the system.

 

I have an application that needs to do some things when the device is going to power off and right now its a race condition of weither or not I finish in time.

 

I'd like to be able to request another second or so from the device, is there any avenue for doing this?

 

thanks!

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Block on device power off

Try pushing global screen with MODAL flag.

 

E.

Contributor
Posts: 22
Registered: ‎01-12-2011
My Device: Not Specified

Re: Block on device power off

Thanks Maadani, I will look into that.

Can you think of any other ways that dont involve a screen? My app doesnt really have a GUI so I'd like to try to find a solution that doesnt involve pushing a screen. thanks!
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Block on device power off

Maybe if you would give a bit more info on what you are trying to do and how, we can improve a bit the performance...

 

E.

Contributor
Posts: 22
Registered: ‎01-12-2011
My Device: Not Specified

Re: Block on device power off

I'm not tryign to make a commercial project its just for personal use and an excuse to learn more BB programming. Its simliar to Google Lattitude but lamer and just for my spouse and I. But the app is for us to track where our phones are. I have set up a personal server and the device app posts every so often (configurable) the current location. The race condition I'm facing is that when the device is powering off I want to post to my server that the device is turning off. But It seems to be hit or miss weither or not I finish my post in time. I dont have a gui its just a application that runs on startup.

 

Any ideas?

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Block on device power off

In that case, I wouldn't spend much time on it.

 

You would have the same problem when getting out of WIFI/Data range...

 

Configure a timeout on your server and mark the certain device unreachable. It will be much simpliar...

 

E. 

Contributor
Posts: 22
Registered: ‎01-12-2011
My Device: Not Specified

Re: Block on device power off

Well the reason for wanting to send the 'i'm shuttong off' is so that I can attempt to tell the different between power off and out of data signal.

 

Itsreally just a for fun project, I realize sometimes it might power off out of data range then I'm SOL but I would still like to have a 'i'm powering off' message when the phone is in data range.

 

Is there no other ways to block on power off? Or request from the OS a few more seconds?

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Block on device power off

Try to implement powerOffRequested in SystemListener2 instead.

 

Here is the link to the docs:

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/SystemListener2.html#po...

 

This event happens before the powerOff and it might give you the second that you need.

 

Hope that helps,

 

E.