Fast App Resume issues in windows phone 8

后端 未结 2 491
耶瑟儿~
耶瑟儿~ 2021-02-06 09:44

When i set ActivationPolicy=\"Resume\" in WMAppManifest.xml page tile navigation(navigation URL) is not working in Tombstone state, it reloads the last back stack page(URL). It

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 10:00

    Adding ActivationPolicy="Resume" is not the only step needed to have your app support Fast App Resume. I believe the behavior you are describing is normal when you only set that one property. I think there are a few ways to implement "Fast App Resume", but I found this to be the easiest way.

    Set the activation policy like you just described and then do the following:

    Go into App.xaml.cs in the "App" class add:

       private bool reset
    

    You should then have a method for InitializePhoneApplication that initializes the RootFrame. Add this:

    RootFrame.Navigating += RootFrame_Navigating;
    RootFrame.Navigated += RootFrame_Navigated;
    

    Then you can go and add those methods:

    void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
    {
        if (reset && e.IsCancelable && e.Uri.OriginalString == "/MainPage.xaml")
        {
            e.Cancel = true;
            reset = false;
        }
    }
    
    void RootFrame_Navigated(object sender, NavigationEventArgs e)
    {
        reset = e.NavigationMode == NavigationMode.Reset;
    }
    

    If you implement this properly, your app should resume from the last page you were on.

提交回复
热议问题