2014-11-06 63 views
1

我有一个在XDK中开发的应用程序。该应用程序链接到一个外部网站(实际上是PDF)。launchExternal不适用于Android上的XDK应用程序

我试过window.open(url,"_system")intel.xdk.device.launchExternal(url),并且在使用英特尔App Preview应用程序时都可以在IOS和Android上运行。

然而,一旦构建已经完成,应用程序被上传到Play商店,外部链接不工作。我还不能说IOS,因为苹果公司还没有完成测试应用程序,但在Android上,就好像这个链接不存在一样。根本没有回应。即使添加try/catch循环也不会产生更多信息。

我意识到,因为链接产生PDF,Android设备必须安装PDF查看器才能查看它,但是我的测试设备确实有有一个,并且如从App Preview运行时所述,它会下载PDF并提示在Adobe中查看它。

任何想法?有没有一个插件,我必须检查Cordova的launchExternal工作选项?

回答

4

为了使用intel.xdk.device.launchExternal(url),您需要包括在项目面板>科尔多瓦3.X混合移动应用程序设置英特尔XDK插件组下的设备插件>插件包括>精选&定制科尔多瓦插件>设备。

为了使用window.open(url,"_system")打开一个URL撬动科尔多瓦inAppBrowser插件,您需要包括在项目面板>科尔多瓦3.X混合移动应用程序设置的应用程序内浏览器插件>插件包括>标准科尔多瓦插件>在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> 
+0

完美!这工作。谢谢! – AaronF 2014-11-07 20:03:40

0

请注意,intel.xdk.device.launchExternal现在已经过时。使用默认inappbrowser APi的是这样的:window.open( “市场://细节ID =?”, “_blank”, “位置=无”)

相关问题