I have the same problem:
http://social.msdn.microsoft.com/Forums/wpapps/en-us/af8615e7-8e90-4069-aa4d-3c4a84a6a3d0/windows-phone-8-fast-app-resume-with-deeplinks?forum=wpdevelop
I am not an expert in C # or WP, so please bear with me.
- I have secondary tiles that reference "/MainPage.xaml?id=XX".
- I have a quick application renewal. (ActivationPolicy = "Resume" in the application manifest)
- I have only one page in my application: MainPage.xaml.
Problem . When I resume the application using the secondary tile ("/MainPage.xaml?id=XX"), I get a brief overview of the previous instance (which would resume) and then MainPage is initialized again, creating a new instance. In fact, the application loads from scratch after I looked at what was previously open.
This is clearly undesirable behavior. I want to use an existing instance to accomplish my task.
Attempt 1 : Use e.Cancel = true;to cancel navigation to MainPage.xaml:
(using the App.xaml.cs code from the official quick sample application summary example to determine how the application was launched)
...
else if (e.NavigationMode == NavigationMode.New && wasRelaunched)
{
wasRelaunched = false;
if (e.Uri.ToString().Contains("="))
{
sessionType = SessionType.DeepLink;
e.Cancel = true;
}
}
...
. OnNavigatedTo , .
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
String navId;
if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
{
if (NavigationContext.QueryString.TryGetValue("id", out navId))
{
MessageBox.Show(navId.ToString());
}
}
...
2:
e.Cancel = true;, MainPage.xaml, Uri MainPage:
...
else if (e.NavigationMode == NavigationMode.New && wasRelaunched)
{
wasRelaunched = false;
if (e.Uri.ToString().Contains("="))
{
sessionType = SessionType.DeepLink;
e.Cancel = true;
MainPage.GoToDeepLink(e.Uri);
}
}
...
public static void GoToDeepLink(Uri uri)
{
string path = uri.ToString();
string id = path.Substring(path.LastIndexOf('=') + 1);
MyList list = App.ViewModel.ListFromId(Convert.ToInt32(id));
pivotLists.SelectedItem = list;
}
. , pivotLists . , , , MainPage (MainPage newMainPage = new MainPage();) newMainPage.pivotLists.SelectedItem = list; - , newMainPage one/replace ... -, / /.
, , . , , , .
.