【问题标题】:Launch an external app from an App从应用程序启动外部应用程序
【发布时间】:2016-04-07 15:22:11
【问题描述】:

我正在使用 Ionic 框架创建一个 android 应用程序,我想从我的应用程序启动一个外部应用程序。

我在 config.xml 中包含了 access-orgin

<access origin="speedtest:*" launch-external="yes"/>

我正在使用以下代码

<button class="button button-positive" ng-click="btnClick()"> Launch Speed Test</button>

在我的 app.js 中

 function onDeviceReady() {

        var scheme;

        // Don't forget to add the org.apache.cordova.device plugin!
        if(device.platform === 'iOS') {
            scheme = 'speedtest://';
        }
        else if(device.platform === 'Android') {

            scheme = 'org.zwanoo.android.speedtest';
        }
        $scope.btnClick = function() {
            appAvailability.check(
            scheme, // URI Scheme
            function() {  // Success callback

                window.open('speedtest://', '_system', 'location=no');

                console.log('Speedtest is available');
            },
            function() {  // Error callback
            //alert("not available");
                window.open('https://play.google.com/store/apps/details?id=org.zwanoo.android.speedtest', '_system', 'location=no');
                console.log('Speedtest is not available');
            }
        );
        } 

    } 

以下行不起作用,它不会在控制台中引发任何错误。

window.open('speedtest://', '_system', 'location=no');

请指导我。

【问题讨论】:

标签: android cordova ionic-framework phonegap-plugins


【解决方案1】:

您可以使用第三方插件启动外部应用程序。请点击以下链接

Plugin for check or launch other application in android device

例如

检查已安装的应用程序

navigator.startApp.check("com.application.name", function(message) { /* success */
    console.log(message); // => OK
}, 
function(error) { /* error */
    console.log(error);
});

启动外部应用程序

navigator.startApp.start("com.application.name", function(message) {  /* success */
    console.log(message); // => OK
}, 
function(error) { /* error */
    console.log(error);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    • 2019-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-08
    相关资源
    最近更新 更多