0

我正在为金融部门构建一个 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

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

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

4

1 回答 1

0

节省时间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;
    }
}
于 2014-01-06T12:31:08.723 回答