码迷,mamicode.com
首页 > 其他好文 > 详细

UWP 协议启动

时间:2017-10-24 13:12:25      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:root   alt   open   client   部署   err   end   style   start   

1.创建通过协议启动的项目 AppDemo

2.在项目的Package.appxmanifest 文件里 Extensions 目录下

技术分享
      <Extensions>
        <uap:Extension Category="windows.protocol">
          <uap:Protocol Name="uridemo">
            <uap:Logo>Assets\StoreLogo.png</uap:Logo>
            <uap:DisplayName>AppDemo</uap:DisplayName>
          </uap:Protocol>
        </uap:Extension>
      </Extensions>
View Code

3.在App.xaml.cs里

技术分享
        protected override void OnActivated(IActivatedEventArgs args)
        {
            base.OnActivated(args);
            // Window management
            Frame rootFrame = Window.Current.Content as Frame;
            if (rootFrame == null)
            {
                rootFrame = new Frame();
                Window.Current.Content = rootFrame;
            }
            switch (args.Kind)
            {
                case ActivationKind.VoiceCommand:
                    {
                        break;
                    }
                case ActivationKind.Protocol:
                    {
                        // Code specific to launch for results
                        var command = args as ProtocolActivatedEventArgs;

                        if (command.Uri.ToString().StartsWith("uridemo://"))
                        {
                            // Open the page that we created to handle activation for results.
                            rootFrame.Navigate(typeof(MainPage), command);

                        }
                        else
                        {
                            //.....
                        }
                        break;
                    }
            }

            // Ensure the current window is active.
            Window.Current.Activate();
        }
View Code

4.在创建一个要启动的项目AppClient

技术分享
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            await Windows.System.Launcher.LaunchUriAsync(new Uri("uridemo://appdata"));
        }
View Code

5.部署完成,启动AppClient

UWP 协议启动

标签:root   alt   open   client   部署   err   end   style   start   

原文地址:http://www.cnblogs.com/luquanmingren/p/7722827.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!