首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows Phone 8- 15分钟后禁用快速应用程序切换(FAS)

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

Stack Overflow用户
提问于 2014-01-06 20:06:44
回答 1查看 197关注 0票数 0

我正在为金融部门构建一个Windows Phone 8应用程序。由于它包含信用卡号码等敏感信息,我需要在快速应用程序切换时设置15分钟超时,即,如果用户在15分钟内“挂起”应用程序并单击“上一步”按钮返回应用程序,它应该会恢复。如果超过15分钟,则应重定向回登录页面。

我曾尝试将OnNavigateFrom和To方法与dispatcher计时器结合使用,但这样做有两个问题。1、当应用挂起时,后台进程不运行,因此计时器停止。2、我的应用程序有多个页面,并且没有给应用程序任何警告,它即将被暂停。我无法区分在应用程序中从一个页面导航到另一个页面,还是完全离开应用程序。

那么,有没有可能在应用程序挂起的同时运行计时器?如果做不到这一点,我如何完全关闭FAS,并在每次应用程序恢复时简单地重新启动登录?我知道这违背了Windows Phone 8的一些可用性原则,但使用这款应用的金融机构有一些需要满足的要求。

有关此主题的Microsoft指南如下所示:

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

以下是此页面的摘录:

“如果距离用户上次访问已有很长一段时间,请重新启动应用程序”

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

编辑:

多亏了crea7or的回答,我现在知道了Application_Deactivated和Application_Activated方法。我已经在独立存储中保存了时间,并在Actived方法中进行了比较。我已经尝试了以下两种解决方案。在这个例子中,什么都没有发生(没有错误但没有效果):

代码语言:javascript
复制
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中的答案,我也尝试过这个

代码语言:javascript
复制
 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类型转换上失败。有什么想法...?

EN

Stack Overflow用户

发布于 2014-01-06 20:31:09

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

代码语言:javascript
复制
MyUriMapper myMapper = new MyUriMapper();
myMapper.forceToStartPage = true;
RootFrame.UriMapper = myMapper;

..clear the other sensitive data of your app (cards info etc.)

其中:

代码语言:javascript
复制
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;
    }
}
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20949709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档