Windows Phone 8-15分钟后禁用快速应用程序切换(FAS)



我正在为金融行业开发一款Windows Phone 8应用程序。由于它包含信用卡号等敏感信息,我需要在快速应用程序切换上暂停15分钟,即如果用户"暂停"应用程序,并在15分钟内点击"返回"按钮返回,它应该会恢复。如果超过15分钟,则应重定向回登录页面。

我曾尝试将OnNavigateFrom和To方法与调度程序计时器结合使用,但这有两个问题。1,当应用程序挂起时,后台进程不会运行,因此计时器停止。2,我的应用程序有多个页面,并且没有向应用程序发出即将暂停的警告。我无法区分在应用程序中从一页导航到另一页,以及完全离开应用程序导航。

那么,在应用程序暂停时,有可能让计时器运行吗?如果不能做到这一点,我如何完全关闭FAS,并在每次恢复应用程序时重新启动登录?我知道这违背了Windows Phone 8的一些可用性精神,但使用该应用程序的金融机构有某些要求需要满足。

微软关于这个主题的指导方针如下:

http://msdn.microsoft.com/en-us/library/windows/apps/hh465088.aspx

以下是本页的摘录:

但不幸的是,没有提到如何真正做到这一点。。。?

编辑:

感谢crea7or的回答,我现在知道了Application_Dactivated和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

我也试过这个,根据这个问题的答案:

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演员阵容中失败了。有什么想法吗。。。?

Application_Deactivated中的时间保存到IsolatedStorageSettings中,并显式调用Save()。读取Application_Activated上的时间,如果超时,请将UriMaper替换为以下内容:

MyUriMapper myMapper = new MyUriMapper();
myMapper.forceToStartPage = true;
RootFrame.UriMapper = myMapper;
..clear the other sensitive data of your app (cards info etc.)

其中:

public class MyUriMapper : UriMapperBase
{
public bool forceToStartPage { get; set; }
public override Uri MapUri( Uri uri )
{
if ( forceToStartPage )
{
forceToStartPage = false;
uri = new Uri( "/Login.xaml", UriKind.Relative );
}
return uri;
}
}

最新更新