2014-01-06 38 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