Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent automatic screen lock on Windows Phone 8

I have written an app that performs some lengthy operations, such as web requests, in a background thread. My problem is that after a while the automatic screen lock turns the screen off and my operations are aborted.

Is there a way to prevent the screen to be automatically turned off during these operations? Or is it in some way possible to keep running while screen is turned off?

I know there are ways to prevent the screen to turn off while debugging, but i need this behavior in the hands of the end user. Therefore I can not rely on some setting being set on the phone, but rather some programmatic solution.

like image 355
PKeno Avatar asked Apr 11 '13 07:04

PKeno


1 Answers

The screen can be forced to stay on using the UserIdleDetectionMode property of the current PhoneApplicationService.

To disable automatic screen lock:

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

To enable it again:

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;

More information can be found on MSDN

like image 90
PKeno Avatar answered Jan 15 '23 02:01

PKeno