【问题标题】:Screen unlock issue屏幕解锁问题
【发布时间】:2014-01-14 07:17:00
【问题描述】:

我的 Windows Phone 应用程序在锁定屏幕下运行。如果我将我的应用程序保持在前台并保持屏幕锁定一段时间,我会在解锁手机时在黑屏上收到一条消息“正在恢复...”。 此消息会显示一段时间,然后我的应用程序将停用。然后我需要重新启动应用程序。 有时仅会观察到此问题。在其他情况下,当手机解锁时,应用程序仍处于前台。

如果有人遇到类似问题并知道相同的解决方案,请帮助我。

【问题讨论】:

    标签: windows-phone-7 windows-phone-8 windows-phone


    【解决方案1】:

    当另一个应用程序启动时,一个应用程序被发送到后台“休眠”,因此您的应用程序被发送到后台。当应用程序在锁屏下运行时消耗大量资源时,也会发生这种情况,以节省电池电量,操作系统会停用应用程序。

    当您恢复应用程序时,您必须有一个不再有效的依赖项或对象导致应用程序崩溃。您应该能够查看堆栈跟踪以确定导致问题的对象。

    您可以更改应用程序恢复时发生的情况以防止出现此问题

    App.xml.cs

    其中包含 4 种方法,可让您更改开始、暂停、恢复、关闭行为。

    private void Application_Launching(object sender, LaunchingEventArgs e)
    {
    }
    
    // Code to execute when the application is activated (brought to foreground)
    // This code will not execute when the application is first launched
    private void Application_Activated(object sender, ActivatedEventArgs e)
    {
    }
    
    // Code to execute when the application is deactivated (sent to background)
    // This code will not execute when the application is closing
    private void Application_Deactivated(object sender, DeactivatedEventArgs e)
    {
    }
    
    // Code to execute when the application is closing (eg, user hit Back)
    // This code will not execute when the application is deactivated
    private void Application_Closing(object sender, ClosingEventArgs e)
    {
    }
    

    【讨论】:

      【解决方案2】:

      如果您想在锁定屏幕下运行应用程序,请禁用 ApplicationIdleDetection - 此站点上有很多帖子您可以找到更多信息 - for example.
      @topher91 是对的 - 如果没有禁用 IdleDetection,您的应用会在锁定屏幕激活时进入休眠(或墓碑)状态,他指出您可以在哪里保存变量/资源以在应用处于活动状态时将它们带回。

      【讨论】:

        猜你喜欢
        • 2016-05-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-22
        • 2018-12-13
        相关资源
        最近更新 更多