2013-06-18 69 views
1

我试图从Phonegap应用程序直接打开Goog​​le Play应用程序详细信息页面。 我在HTML页面中加入这一行:从Phonegap链接到Google Play应用程序:不支持协议

<a href="market://details?id=com.publishername.myapp">Link to market</a> 

不幸的是,我得到这个错误:

The protocol isn't supported. (market://details?id=com.publishername.myapp). 

我试图找到没有成功,在谷歌的解决方案。

+0

??? 'http://'不够好? – ozbek

+0

@shoe rat我想要打开Goog​​le Play应用程序,而不是网络浏览器。 Http只打开网页浏览器。 – poiuytrez

+0

它现在工作,谢谢:) –

回答

2

我在cordova bug跟踪器中报告了这个问题。
https://issues.apache.org/jira/browse/CB-3902

开发团队刚刚致力于解决这个问题。它应该固定在科尔多瓦2.9。

+1

科尔多瓦错误跟踪器中的修复是荒谬的,因为他们已经硬编码market://作为支持的URL。怎么样由WebIntent Cordova插件触发的自定义URL .. MYAPP:// – silverchair

1

我还没有与PhoneGap的工作,但如果我需要从一个HTML页面启动Play商店这里是我会怎么做:

的Java

public class MyClass extends AbstractClass { 
    // lots of lines of code 

    WebView webView = (WebView) findViewById(R.id.webview); 
    webView.addJavascriptInterface(new WebAppInterface(this), "PlayStore"); 

    // moar code 

    public class WebAppInterface { 
     Context mContext; 

     WebAppInterface(Context c) { 
      mContext = c; 
     } 

     @JavascriptInterface 
     public void launch() { 
      Intent intent = new Intent(Intent.ACTION_VIEW, 
        Uri.parse("market://details?id=com.publishername.myapp")); 
      mContext.startActivity(intent); 
     } 
    } 

    // and many moar 
} 

HTML/JavaScript的

<!DOCTYPE html> 
<html> 
<head> 
    <script type="text/javascript"> 
     function launchPlayStore() { 
      PlayStore.launch(); 
     } 
    </script> 
</head> 

<body> 
    <!-- lots of lines of html --> 

    <a href="javascript:launchPlayStore();">Link to market</a> 

    <!-- moar html --> 
</body> 
</html> 
+0

这是困难的方式:)。我很确定这个简单的链接与以前的电话版本一起工作。 – poiuytrez