【问题标题】:How to launch Universal Windows app from another Universal Windows app installed in the same system?如何从安装在同一系统中的另一个通用 Windows 应用程序启动通用 Windows 应用程序?
【发布时间】:2019-01-02 04:28:36
【问题描述】:

我的要求是在另一个通用 Windows 应用程序中执行按钮单击时启动通用 Windows 应用程序, 我的应用程序是用 javascript 开发的。

不起作用的示例, 它在 Windows 10 桌面上运行良好,但在 Windows IOT 操作系统上无法运行:

$(document).on('click', '.openDPPA', function () {
    document.getElementById("demo1").innerHTML = 1;
    try {
        var testAppUri = new Windows.Foundation.Uri("test2-app2app:");
        var n = new Windows.System.LauncherOptions();
        options.TargetApplicationPackageFamilyName = "DPPAApp_ehke6zp0mbebr";
    }

    catch (err) {
        document.getElementById("demo").innerHTML = err.message;
    }
    Windows.System.Launcher.launchUriAsync(testAppUri, options).then(
        function (success) {
            if (success) {
                // URI launched
                x = "success";
                $("#errorLabel").html("success");
            } else {
                x = "failed";
                $("#errorLabel").html("failed");
                // URI launch failed
            }
        });

});

尝试将错误消息显示为

无法获取未定义或空引用的属性。

【问题讨论】:

  • 您控制您尝试启动的应用程序吗?最简单的解决方案可能是为应用注册一个自定义方案(“协议”)并通过Launcer.launchUriAysnc() 启动它
  • 彼得你知道任何相同的文件吗。
  • 请参考Handle URI activation。
  • 谢谢彼得和尼科,我做到了。但如果可能的话,我面临另一个问题,请重播stackoverflow.com/questions/51631652/…
  • 在这种情况下,我认为错误的问题是您在第一行调用LauncherOptionsn,但在第二行调用options

标签: javascript uwp


【解决方案1】:

以下代码适用于 Windows IoT Core

$(document).on('click', '.openDPPA', function () {
       try {
            var testAppUri = new Windows.Foundation.Uri("test2-app2app:");
            var n = new Windows.System.LauncherOptions();
            options.TargetApplicationPackageFamilyName = "DPPAApp_ehke6zp0mbebr";
            options.treatedAsUntrusted = false;
        }

        catch (err) {
            document.getElementById("demo").innerHTML = err.message;
        }
        Windows.System.Launcher.launchUriAsync(testAppUri, options).then(
            function (success) {
                if (success) {
                    // URI launched

                } else {

                    // URI launch failed
                }
            });

    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 2016-10-14
    • 1970-01-01
    • 2017-03-11
    • 1970-01-01
    相关资源
    最近更新 更多