Quirk: App invocation from secondary tile with app currently running #win8dev

My cineworld app for Windows 8 is now in Store and thanks to many of my dev friends, I am getting bug reports and feature requests.

Anthony Wieser just found another bug for me. The app is running and you have two cinemas in pinned state: Enfield and Cambridge. Hit Start and open one of the pinned cinema, the app shows the view you left it at. No navigation to desired cinema.

To resolve this issue, I set the app to debug and then opened App.xaml.cs and as I was putting a break point in OnActivatedMethod, I saw this

// Do not repeat app initialization when already running, just ensure that
// the window is active
if (args.PreviousExecutionState == ApplicationExecutionState.Running)
{
   Window.Current.Activate();
   return;
}

var rootFrame = new Frame();
SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

if (rootFrame.Content == null)
{
... // so on and so forth
}

this is the culprit. What I should be doing is checking params passed and then showing the correct xaml page. time to fix it now.

Update: Fixed. here’s what I have done :)

if (args.PreviousExecutionState == ApplicationExecutionState.Running)
{
    if (iCin == int.MinValue)
    {
        Window.Current.Activate();
        return;
    }
    else
        rootFrame = (Frame)Window.Current.Content;
}
else
{
    // Create a Frame to act as the navigation context and associate it with
    // a SuspensionManager key
    rootFrame = new Frame();
    SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
}

if (rootFrame.Content == null || iCin != int.MinValue) // the iCin contain value passed in activation param
{
... // so on and so forth
}

once you do this, you can handle navigation params and navigate to correct xaml page.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s