Performing actions before going into sleep mode

  • Thread starter Thread starter maluman
  • Start date Start date
M

maluman

Welcome

First, I apologize if that topic was already described, but I didn't
even know what keywords would match this case in google (the ones I
searched, didn't give me any answer at all), so:

I'd like to execute some code before device suspends, when user press
"OFF" switch. Can it be easily done?

Thanks in advance for any help/links.
 
You might be able to catch the pressing of the off button and execute some
code there. Not sure about automatic suspension/standby of the device
though. I supose you could implement some kind of timer that is reset each
time the device goes on and execute some code right before the standby time
(which is calculated by that timer) - far-fetched but may work in your case.
 
Not sure about automatic suspension/standby of the device
though. I supose you could implement some kind of timer that is reset each
time the device goes on and execute some code right before the standby time
(which is calculated by that timer) - far-fetched but may work in your case.

Thanks for your previous advice. According to autosuspend, is there
something 100% reliable?
Aren't there any messages being sent to applications before going to sleep?
 
Alex developed this code sample:

http://www.alexfeinman.com/dow­nload.asp?doc=PowerAwareApp.zi­p

Note that in my experience there is not enough time to do much before
the device powers off when the user presses the "OFF" switch.

Perhaps you can do this when you get the power-on notification? e.g. in
my case, the user required that any power-off throws the user to the
login screen. This is actually caught at power-on.
 
Back
Top