C#UWP启动应用程序 [英] C# uwp launch apps

查看:227
本文介绍了C#UWP启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码:

await Windows.System.Launcher.LaunchUriAsync(new Uri(@"ms-windows-store://review/?ProductId=9wzdncrfj2wl"));

我正在Microsoft Store中打开Facebook应用程序.该页面上有一个启动按钮.用户可以使用它运行应用程序.

I am opening Facebook app in Microsoft Store. There is a Launch button on that page. With it user runs the application.

如何使用产品ID运行应用程序?

How can I run the application with it's product ID?

我设法用以下代码打开了应用程序:

I managed to open app with this code:

await Windows.System.Launcher.LaunchUriAsync(new Uri("fb:post?text=foo"));

但是我想用ID打开它.

But I want to open it with ID.

我找到了此代码,但是它不起作用:

I have found this code, but it is not working:

await Windows.System.Launcher.LaunchUriAsync(new Uri(@"ms-windows-store://pdp/?ProductId=9wzdncrfj2wl"));

如何打开带有ID的已安装应用程序?或者,如果有另一种方法可以检查是否已安装应用程序,则先启动它,再将其显示在商店中,以便用户手动安装.我正在开发的应用是Windows 10 UWP ...

How to open installed app with ID? Or, if there is another way to check if App is installed, if it is then launch it, if it is not then show it in store, so user can install it manually. The app I am developing is Windows 10 UWP...

我遇到的情况是没有适用于应用程序的URI,因此我必须通过它的ProductID或ProductFamily打开它.

I have a situation where there is no URI for application, so I have to open it via it's ProductID or ProductFamily...

因此,这是打开该应用程序的快捷方式的目标: C:\ Windows \ explorer.exe shell:AppsFolder \ A88BB54F.N1info_gvc78jvcn5cg0!App

So, this is the shortcut's target that is opening that app: C:\Windows\explorer.exe shell:AppsFolder\A88BB54F.N1info_gvc78jvcn5cg0!App

我是否有可能在UWP应用中使用它来启动应用?

Is there any chance I can use this in UWP app to launch app?

有人从Windows应用商店中的启动"按钮获得链接吗?因此,我会将其放在URI中,就像GET按钮中的链接一样:

Does anyone got the link from LAUNCH button in Windows Store? So, I would put that in URI, just like link from GET button:

ms-windows-store:PDP?PFN=A88BB54F.N1info_gvc78jvcn5cg0&referrer=unistoreweb&webig=39694073-f9af-436f-a82b-abb9d9f644f0&muid=097C7AA3CA2C6EE22D237359CE2C689A&websession=c9916902dd014ec2b5a9e0390a28c26d

我正在这样使用它:

await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:PDP?PFN=A88BB54F.N1info_gvc78jvcn5cg0&referrer=unistoreweb&webig=39694073-f9af-436f-a82b-abb9d9f644f0&muid=097C7AA3CA2C6EE22D237359CE2C689A&websession=c9916902dd014ec2b5a9e0390a28c26d"));

它正在商店中显示应用程序.

and it is showing app in store.

感谢.

推荐答案

或者,如果还有另一种方法可以检查是否已安装应用程序,请先启动它,然后再将其显示在商店中,以便用户手动安装.

Or, if there is another way to check if App is installed, if it is then launch it, if it is not then show it in store, so user can install it manually.

您可以调用 Launcher.QueryUriSupportAsync 来查看是否已安装该应用程序.此方法将返回 LaunchQuerySupportStatus枚举值,您可以决定通过此值打开应用或Windows存储.

You could call Launcher.QueryUriSupportAsync to see if the app is installed. This method will return LaunchQuerySupportStatus enumeration value, you could decide to open the app or windows store by this value.

请检查以下代码以获取详细信息:

Please check the following code for details:

var ret = await Windows.System.Launcher.QueryUriSupportAsync(new Uri("fb:post?text=foo"), Windows.System.LaunchQuerySupportType.Uri);
if (ret == LaunchQuerySupportStatus.Available)
{
    await Windows.System.Launcher.LaunchUriAsync(new Uri("fb:post?text=foo"));
}
else
{
    await Windows.System.Launcher.LaunchUriAsync(new Uri(@"ms-windows-store://pdp/?ProductId=9wzdncrfj2wl"));
}

这篇关于C#UWP启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆