UWP 协议启动
2024-10-01 04:42:13
- 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>
- 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();
}
- 4.在创建一个要启动的项目AppClient
private async void button_Click(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("uridemo://appdata"));
}
- 5.部署完成,启动AppClient
最新文章
- JAVA GC 简单总结
- 给tabBar设置图片和字体颜色的几种方法
- [QualityCenter]设置工作流脚本-设置不同字段值关联不同列表
- 优化后的二次测试Miller_Rabin素性测试算法
- 国际制造执行系统(MES)应用与发展
- CentOS 搭建LNMP服务器和LAMP服务器
- [Oracle]Oracle学习小结(1)
- Java网络编程(TCP协议-服务端和客户端交互)
- Verilog HDL中阻塞语句和非阻塞语句的区别
- 关于虚拟机装kali-linux的联网问题
- 【Java基础】对象的具体创建过程
- Java学习笔记之I/O流(读取压缩文件以及压缩文件)
- POP音原因
- OC字符串的使用(一)
- 用Qemu运行/调试arm linux【转】
- gin框架使用注意事项
- 合肥.NET技术社区首次线下聚会全程回顾【多图】
- Python Learning: 03
- 动态规划-poj1949
- 0703-spring cloud config-git配置属性加解密之对称加密