Monday, 10 January 2011

Keeping your Smartphone alive for background processing

Want to keep your windows mobile smart phone alive, even if the user is trying to force it off?

This can be achieved by using the unattended mode, the power manager on Windows Mobile has an unattended state that will effectively look like the phone is off but the CPU will be running in the background with the LCD off. This is used for playing music, downloading emails etc. To invoice this

PowerPolicyNotify(PPN_UNATTENDEDMODE, 1);

To release this do

PowerPolicyNotify(PPN_UNATTENDEDMODE, 0);

Whist in this state you may need to poke the device to stay on by calling the above function again. If you want to wake up the device then use another power API:

// Force backlight and power on
SetSystemPowerState(NULL, POWER_STATE_ON, POWER_FORCE);

This will force the system to wake up fully if you want to display information to the user after your background processing.

No comments: