Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

backlight - Can I prevent screen timeout on Windows Phone 7?

In the CE based Windows Mobile you could prevent the screen back-light from timing out using the SetPowerRequirement and ReleasePowerRequirement API's like so:

IntPtr handle = SetPowerRequirement("BKL1:", PowerState.FULL, 1, IntPtr.Zero, 0);
// screen won't timeout while you do stuff in here
ReleasePowerREquirement(handle);

Is a similar thing possible on WP7?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, it is possible. You can use PhoneApplicationService.Current.UserIdleDetectionMode to stop the screen backlight timing out and stop the screen from locking.

You can also use PhoneApplicationService.Current.ApplicationIdleDetectionMode to allow the application to keep running under a lock screen.

Here's some more detail on those two options:

UserIdleDetectionMode

Disabling this will stop the screen from timing out and locking. As an example, I disable UserIdleDetectionMode while downloading a large file, so the app doesn't kill the download half-way.

When the download is completed, I re-enable UserIdleDetectionMode so the screen can timeout as usual.

ApplicationIdleDetectionMode

NB: This is a one-time hit. You can disable it, but you cannot re-enable it.

If you disable ApplicationIdleDetectionMode, your app will continue to run when the screen locks. Your app will still die if the user starts a different app.

The certification requirements ask that you prompt the user the first time you disable ApplicationIdleDetectionMode. E.g. "This app will continue to run under a locked screen, and may drain your battery. Are you ok with that?" If you don't your app will be rejected.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...