2014-01-14 223 views
0

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

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

回答

2

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

当您恢复应用程序时,您必须具有不再有效的依赖项或对象,导致应用程序崩溃。你应该能够看看栈跟踪来识别哪个对象导致了问题。

可以更改时会发生什么应用程序在恢复,以防止这个问题

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) 
{ 
} 
1

如果要在锁屏界面上运行应用程序,然后关闭ApplicationIdleDetection - 有许多岗位在这个网站,你可以找到更多信息 - for example
@ topher91是正确的 - 没有禁用IdleDetection当锁屏激活时,你的应用程序进入休眠(或墓碑状态)状态,他指出你可以在哪里保存变量/资源,以使应用程序处于激活状态。