简体   繁体   中英

Adding UriMapper for WindowsPhone in Universal Application

I'm struggling creating an universal app out of an existing windows phone 8.1 app. I used the AssociationUriMapper as described here and I can't find a way to use this in the universal app. The System.Windows.Navigation namespace does not exist and therefore I can't override the UriMapperBase .

Anyone know where this goes wrong and what I have to do to keep the functionality even in an universal app ( without offering the same feature to windows 8.1 app )?

How apps handle Uris on launch has changed a lot since Windows Phone 8. Previously, the app would get passed a Uri which require a lot of parsing to be of any use - hence the need for a UriMapper, which Microsoft provides.

For Windows Phone 8.1 and Windows 8.1 (ie. Universal XAML apps), app activation is handled (by OpenFilePicker, ShareTarget, Protocol, etc) is handled by the OnActivated method...

protected override void OnActivated(IActivatedEventArgs args)
{
    if (args.Kind == ActivationKind.Protocol)
    {
        ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;

    // TODO: Handle URI activation
    // The received URI is eventArgs.Uri.AbsoluteUri
    }
}

Source: official MSDN documentation

After determining the ActivationKind and casting to the right EventArgs type, it's then just a matter of parsing the parameters of the data.

There's also an example Universal app on that page which details a few of these scenarios.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM