1

我正在尝试从 Phonegap 应用程序直接打开 Google 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). 

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

4

2 回答 2

2

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

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

于 2013-06-19T07:45:43.743 回答
1

我没有使用过 Phonegap,但如果我需要从 HTML 页面启动 Play 商店,我会这样做:

爪哇

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>
于 2013-06-18T12:03:23.197 回答