launchExternal 不适用于 Android 上的 XDK 应用程序 [英] launchExternal doesn't work on XDK app on Android

查看:27
本文介绍了launchExternal 不适用于 Android 上的 XDK 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 XDK 开发的应用程序.该应用程序一度链接到外部网站(实际上是 PDF).

I have an application that was developed in XDK. The app links to an external web site at one point (for a PDF actually).

我已经尝试了 window.open(url,"_system")intel.xdk.device.launchExternal(url) 并且都适用于 IOS 和 Android使用英特尔应用预览应用时.

I've tried both window.open(url,"_system") and intel.xdk.device.launchExternal(url) and both work on IOS and Android when using the Intel App Preview app.

但是,一旦构建完成并将应用上传到 Play 商店,外部链接将不起作用.我还不能说 IOS,因为 Apple 还没有完成对应用程序的测试,但是在 Android 上,就好像链接不存在一样.根本没有回应.甚至添加 try/catch 循环也没有产生更多信息.

However, once the build was completed and the app was uploaded to the Play store, the external links do not work. I can't say about IOS yet because Apple hasn't finished testing the app, but on Android, it's as though the link doesn't exist. There is no response at all. Even adding a try/catch loop didn't produce any more information.

我意识到,因为该链接生成了一个 PDF,Android 设备必须安装一个 PDF 查看器才能查看它,但是我的测试设备确实有一个,正如从 App Preview 运行时提到的,它会下载 PDF 并提示在 Adob​​e 中查看.

I realize that because the link produces a PDF that the Android device has to have a PDF viewer installed to view it, however my testing device does have one, and as mentioned when run from App Preview, it downloads the PDF and prompts to view it in Adobe.

有什么想法吗?是否有插件我必须检查 Cordova 选项才能使 launchExternal 工作?

Any ideas? Is there a plugin I have to check off for Cordova options for launchExternal to work?

推荐答案

为了使用 intel.xdk.device.launchExternal(url),您需要在 Intel项目面板上的 XDK 插件组 > Cordova 3.X 混合移动应用程序设置 > 包含的插件 > 特色 &自定义 Cordova 插件 > 设备.

In order to use intel.xdk.device.launchExternal(url), you are required to include the Device plugin under the Intel XDK Plugins group on the Projects Panel > Cordova 3.X Hybrid Mobile App Settings > Included Plugins > Featured & Custom Cordova Plugins > Device.

为了使用 window.open(url,"_system") 打开一个利用 Cordova inAppBrowser 插件的 URL,您需要在项目中包含应用内浏览器插件面板 > Cordova 3.X 混合移动应用设置 > 包含的插件 > 标准 Cordova 插件 > 在应用浏览器中.

In order to use window.open(url,"_system") to open a URL leveraging the Cordova inAppBrowser plugin, you are required to include the In App Browser plugin on the Projects Panel > Cordova 3.X Hybrid Mobile App Settings > Included Plugins > Standard Cordova Plugins > In App Browser.

<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
    <title>Your New Application</title>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
    <style type="text/css">
        /* Prevent copy paste for all elements except text fields */
        *  { -webkit-user-select:none; -webkit-tap-highlight-color:rgba(255, 255, 255, 0); }
        input, textarea  { -webkit-user-select:text; }
        body { background-color:white; color:black }
    </style>
    <script src='intelxdk.js'></script>
    <script src='cordova.js'></script>
    <script src='xhr.js'></script>
    <script type="text/javascript">
        var onDeviceReady=function(){                             // called when Cordova is ready
           if( window.Cordova && navigator.splashscreen ) {     // Cordova API detected
                navigator.splashscreen.hide() ;                 // hide splash screen
            }
        } ;
        document.addEventListener("deviceready", onDeviceReady, false) ;
    </script>
</head>
<body>
    <!-- content goes here-->
    <h2>Hello World</h2>
    <script>
        function openExternal(elem) {
            window.open(elem.href, "_system");
            return false; // Prevent execution of the default onClick handler 
        }
    </script>
    <a href="https://www.twitter.com" onClick="javascript:return openExternal(this)">Twitter</a>
</body>
</html>

这篇关于launchExternal 不适用于 Android 上的 XDK 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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