How to start a third-party application and pass parameters in Windows Phone 8 and Windows 8

Source: Internet
Author: User
Tags relative

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);
        }
    

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.