Jessie Serrino
Jessie Serrino

Reputation: 13

How does one navigate back to their desired page on WP8 after having the app run in the background?

I am currently writing a running tracker, and I want it to be possible for the user to have my application running in the background.

Everything is fine when running it in the background, but whenever I re-open the app, it puts me back at the main menu.

In the end, I want access to the RootFrame.BackStack, so that the user can pick up where they left off.

I tried the following code in my App.xaml.cs but it threw a "InvalidOperationException" at the attempt to access RootFrame.BackStack.GetEnumerator().Current.

Note: I checked, and all values before Current are non-null.

    private void Application_Activated(object sender, ActivatedEventArgs e)
    {
        JournalEntry j;
        if (RootFrame.BackStack.GetEnumerator().Current != null)
            j = RootFrame.BackStack.GetEnumerator().Current;
        RunningInBackground = false;
    }

Upvotes: 1

Views: 552

Answers (2)

madhu kumar
madhu kumar

Reputation: 810

try this sample link. I hope this is what you are looking for. http://code.msdn.microsoft.com/wpapps/Fast-app-resume-backstack-f16baaa6

Upvotes: 0

Olivier Payen
Olivier Payen

Reputation: 15268

What you're looking for is called Fast App Resume:

Windows Phone 8 introduces the ability for apps to request that user actions that would typically relaunch the app, such as tapping the app’s Start Tile, instead resume the suspended instance of the suspended app instance, if one exists. This feature is called Fast Resume.

To enable Fast Resume for your app, add the ActivationPolicy attribute to the DefaultTask element in WMAppManifest.xml and set the value to “Resume”.

<DefaultTask Name="_default" NavigationPage="MainPage.xaml" ActivationPolicy="Resume"/>

Upvotes: 1

Related Questions