【发布时间】:2014-01-06 12:06:44
【问题描述】:
我正在为金融部门构建一个 Windows Phone 8 应用程序。由于它包含信用卡号等敏感信息,我需要在快速应用切换上设置 15 分钟的超时时间,即如果用户“暂停”应用并在 15 分钟内点击返回按钮返回它,它应该会恢复。如果超过 15 分钟,它应该重定向回登录页面。
我曾尝试将 OnNavigateFrom 和 To 方法与调度程序计时器结合使用,但这样做有两个问题。 1、app挂起时后台进程不运行,所以定时器停止。 2、我的应用有多个页面,并且没有给应用发出即将被暂停的警告。我无法区分在应用内逐页导航和完全离开应用导航。
那么,是否可以在应用程序暂停时运行计时器?如果做不到这一点,我如何完全关闭 FAS 并在每次恢复应用程序时简单地重新登录?我知道这违背了 Windows Phone 8 的某些可用性理念,但是将使用此应用程序的金融机构有一些需要满足的要求。
有关此主题的 Microsoft 指南如下:
http://msdn.microsoft.com/en-us/library/windows/apps/hh465088.aspx
以下是该页面的摘录:
“如果自用户上次访问以来已经过了很长时间,则重新启动应用程序”
但不幸的是,没有提到如何实际做到这一点......?
编辑:
感谢 crea7or 的回答,我现在知道了 Application_Deactivated 和 Application_Activated 方法。我已经在隔离存储中节省了时间,并在 Actived 方法中进行了比较。我尝试了以下两种解决方案。在这个中,什么都没有发生(没有错误但没有效果):
Private Sub Application_Activated(ByVal sender As Object, ByVal e As ActivatedEventArgs)
'Get the saved time
Dim settings As IsolatedStorageSettings = IsolatedStorageSettings.ApplicationSettings
Dim stime As DateTime = settings("CurrentTime")
Dim now As DateTime = System.DateTime.Now
If now > stime.AddSeconds(5) Then
Dim myMapper As New MyUriMapper()
myMapper.forceToStartPage = True
RootFrame.UriMapper = myMapper
End If
End Sub
我也试过这个,根据this question中的回答:
Private Sub Application_Activated(ByVal sender As Object, ByVal e As ActivatedEventArgs)
'Get the saved time
Dim settings As IsolatedStorageSettings = IsolatedStorageSettings.ApplicationSettings
Dim stime As DateTime = settings("CurrentTime")
Dim now As DateTime = System.DateTime.Now
If now > stime.AddSeconds(5) Then
DirectCast(App.RootFrame.UriMapper, UriMapper).UriMappings(0).MappedUri = New Uri("/MainPage.xaml", UriKind.Relative)
App.RootFrame.Navigate(New Uri("/MainPage.xaml?dummy=1", UriKind.Relative))
App.RootFrame.RemoveBackEntry()
End If
Ens Sub
但这在 Uri 演员表上失败了。有什么想法吗...?
【问题讨论】:
标签: windows-phone-8 fast-app-switching