2014-01-06 37 views
0

我正在为金融部门构建Windows Phone 8应用。由于包含敏感信息(如信用卡号码),我需要15分钟的快速应用切换超时时间,即如果用户“暂停”应用并在15分钟内点击返回按钮返回该应用,则应恢复。如果超过15分钟,它应该重定向回登录页面。Windows Phone 8 - 15分钟后禁用快速应用切换(FAS)

我已经尝试使用OnNavigateFrom和To方法与调度计时器一起使用,但有2个问题。 1,当应用程序暂停时后台进程不运行,所以计时器停止。 2,我的应用程序有多个页面,并且没有向应用程序发出警告它即将被暂停。我无法区分在应用内的页面之间导航,以及完全导航离开应用。

那么,是否有可能在应用程序暂停时运行定时器?如果不这样做,我该如何彻底关闭FAS,并在每次恢复应用程序时重新启动登录?我知道这违反了Windows Phone 8的一些可用性风格,但是使用这个应用程序的金融机构有一些需要满足的要求。

关于此议题的微软准则在这里:

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演员。有任何想法吗...?

回答

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; 
    } 
} 
+0

感谢您的答复。我不知道Application_Activated和Deactivated方法,所以这很有用。这些方法被调用,但我仍然无法使其导航。我已经创建了mapper类,并且像这样调用它(转换为VB),但没有任何反应; – odinel