繁体   English   中英

从Phonegap链接到Google Play应用:不支持协议

[英]Link to Google Play app from Phonegap : Protocol not supported

我正试图从Phonegap应用程序直接打开Goog​​le Play应用程序详细信息页面。 我在我的html页面中添加了这一行:

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

不幸的是,我收到此错误:

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

我试图在Google上找到一个没有成功的解决方案。

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

开发团队刚刚承诺解决问题。 它应该在Cordova 2.9中修复。

我没有使用过Phonegap,但是如果我需要从HTML页面启动Play Store,我就是这样做的:

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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM