05-23-2012 04:05 PM
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?
Solved! Go to Solution.
05-23-2012 04:20 PM
05-24-2012 10:14 AM
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.
05-24-2012 10:35 AM
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...
05-24-2012 10:49 AM
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?
05-24-2012 04:24 PM
Try to implement powerOffRequested in SystemListener2 instead.
Here is the link to the docs:
This event happens before the powerOff and it might give you the second that you need.
Hope that helps,