Third-party applications that need to be started by other applications need to register Protocol association, and when an application initiates a special URI, the program that registers the protocol automatically starts, and the parameter can be passed to a Third-party application through this particular URI.
Third-party Application Registration Protocol Association steps
There are some differences in how Windows Phone 8 and Windows 8 are registered, as described below.
Windows Phone 8 Third-party application registration Protocol
1. Modify the Wpappmanifest.xaml file
Add a code similar to the following after </Token>:
1 <Extensions>
2 <protocol name= "TestApp" navurifragment= "encodedlaunchuri=%s" taskid= "_default"/>
3 </Extensions>
The Protocol element is a child of the Extensions element and should always be followed by all the filetypeassociation elements. The Protocol element describes the application of the registered URI scheme name so that it can be started when a particular URI is started by another application.
2. Add URI request resolution Handler
Descendants of the program UiR format:/protocol?encodedlaunchuri={descendants of the URI}, in order to enable the program to correctly parse the URI of descendants, you need to add Associationurimapper class for the project, the code is as follows:
<summary>
///parsing third party application invocation parameters
///</summary>
class Associationurimapper:urimapperbase
{
private string Tempuri;
public override Uri Mapuri (Uri uri)
{
Tempuri = URI. ToString ();
Protocol Association launch for Contoso.
if (Tempuri.contains ("/protocol"))
{
int pos = tempuri.indexof ("Encodedlaunchuri");
String encodedstring = Tempuri;
if (POS >= 0)
{
encodedstring = tempuri.substring (POS);
}
return new Uri ("/mainpage.xaml?" + encodedstring, urikind.relative);
}
Include the original URI with the mapping to the main page.
return new Uri ("/mainpage.xaml", urikind.relative);
}