我还没有与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>
??? 'http://'不够好? – ozbek
@shoe rat我想要打开Google Play应用程序,而不是网络浏览器。 Http只打开网页浏览器。 – poiuytrez
它现在工作,谢谢:) –