10-07-2011 05:31 PM
from this post: http://supportforums.blackberry.com/t5/Java-Develo
however for background application, it is a little tricky. There are SystemListener.powerOff and SystemListener2.powerOffRequested could be used to signal a device reboot which could be used to trigger a shutdown of my background application. However what if user cancelled the power off and then my background application would not be running any more.
So just wonder if there is any good practice for shutdown and cleaning up the background process. Or maybe that it doesn't matter since anyway device is rebooting or power off.
Could someone share some insights on this?
Solved! Go to Solution.
10-10-2011 08:35 PM
Besides saving all the data you need, one thing I can think of is to update your system listeners (the listeners which stays active after application / device are shut down. For example, SystemListener). If you want one (or more) of the listeners to be enabled or not, you should do it on shutdown so your application (won't) start working when it (shouldn't) should.
10-11-2011 05:40 AM
I generally use SystemListener.powerOff() but was under the impression that this only got called after the user had agreed the powerOff. Remember that this is normally only a sleep mode so powerOn will be invoked (assuming you leave your System Listener enabled) and you can restart everything. I don't believe there is an indication of a full device power off.
Anyway, I would use powerOff and PowerOn for both UiApplications and Applications.
It is good practice to do this - it will save things like network Threads dieing and not being restarted overnight when the user automatically shuts their BB down.
In the case of UiApplication, often you might want to give the user the option of exiting the application via a menu commend. So you could create a shared exit method that everyone (including the no more screen close), can use.