我還沒有與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
它現在工作,謝謝:) –