2014-11-06 16 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」, 「位置=無」)

相關問題