var uriBing = new Uri(@"chrome://www.bing.com");
var success = Windows.System.Launcher.LaunchUriAsync(uriBing);
如何在UWP应用中打开特定浏览器? 例如,如果用户想要打开" gmail.com",请在Chrome中打开标签。如果用户想要打开dev.windows.com,请打开边缘标签。
答案 0 :(得分:1)
LaunchUriAsync
方法有一个LauncherOptions参数,您可以为其指定TargetApplicationPackageFamilyName
。例如,Edge是" Microsoft.MicrosoftEdge_8wekyb3d8bbwe"。
Uri uri_windows = new Uri("https://developer.microsoft.com/");
var options = new Windows.System.LauncherOptions();
options.TargetApplicationPackageFamilyName = "Microsoft.MicrosoftEdge_8wekyb3d8bbwe";
var success = await Windows.System.Launcher.LaunchUriAsync(uri_windows, options);
但是对于Google browser,我发现它的TargetApplicationPackageFamilyName是" GoogleInc.GoogleSearch_yfg5n0ztvskxp"。但是下面的代码没有用。我不知道为什么。
Uri uri_mail = new Uri("https://mail.google.com");
var _options = new Windows.System.LauncherOptions();
_options.TargetApplicationPackageFamilyName = "GoogleInc.GoogleSearch_yfg5n0ztvskxp";
success = await Windows.System.Launcher.LaunchUriAsync(uri_mail, _options);