我可以防止 Windows Phone 7 上的屏幕超时吗?
在基于 CE 的 Windows Mobile 中,您可以使用 防止屏幕背光超时SetPowerRequirement 和 ReleasePowerRequirement API 如下:
IntPtr handle = SetPowerRequirement("BKL1:", PowerState.FULL, 1, IntPtr.Zero, 0);
// screen won't timeout while you do stuff in here
ReleasePowerREquirement(handle);
是类似的东西WP7上可以吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是可能的。您可以使用
PhoneApplicationService.Current.UserIdleDetectionMode
来阻止屏幕背光超时并阻止屏幕锁定。您还可以使用
PhoneApplicationService.Current.ApplicationIdleDetectionMode
允许应用程序在锁定屏幕下继续运行。以下是有关这两个选项的更多详细信息:
UserIdleDetectionMode
禁用此选项将阻止屏幕超时和锁定。例如,我在下载大文件时禁用 UserIdleDetectionMode,因此应用程序不会中途终止下载。
下载完成后,我重新启用 UserIdleDetectionMode,以便屏幕可以像平常一样超时。
ApplicationIdleDetectionMode
注意:这是一次性的。您可以禁用它,但无法重新启用它。
如果您禁用ApplicationIdleDetectionMode,您的应用程序将在屏幕锁定时继续运行。如果用户启动不同的应用程序,您的应用程序仍然会死掉。
认证要求要求您在第一次禁用 ApplicationIdleDetectionMode 时提示用户。例如“此应用程序将继续在锁定屏幕下运行,并且可能会耗尽您的电池。您同意吗?”如果您不这样做,您的应用程序将被拒绝。
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.