android - Unable to open google play store from android webview
问题描述
I am opening a url in android webview
which is redirecting the user to google play store web page in android webview
and play store page is showing OPEN IN PLAY STORE APP
and while clicking that button rather then opining play store app webview
is redirecting to a web url which is not found.
Now i don't know why it is happening as in google chrome app same scenario is working fine. Please suggest the better solution.
Some code i have done :
mWebView.loadUrl("https://play.google.com/store/apps/details?id=in.org.npci.upiapp&hl=en")
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
return super.shouldOverrideUrlLoading(view, urlNewString);
}
@Override
public void onPageFinished(WebView view, String url) {
}
});
Note: I am using this play store url just as an example.
解决方案
您需要覆盖shouldOverrideUrlLoading
,但您还必须检查 URL,如果它以intent://
方案开头,则有条件地创建一个意图。我们(Android WebView 团队)已经编写了一个示例应用程序来实现这一点。
推荐阅读
- woocommerce - 添加到购物车按钮文本更改基于折扣
- xamarin.forms - FileUploaderPlugin - Android 上的 MultiPartDataMediaFormatterBoundary 错误
- kubernetes - GKE 单个节点可以连接多少个 Persistent Disk?
- javascript - 从 for 循环中的函数回调返回值
- java - Spring Data Rest - @HandleBeforeSave 中发生运行时异常时事务未回滚?
- unit-testing - 测试单次延迟
- angular - Angular ng serve 不包括 polyfill——IE11/Edge 仅在运行 ng build --prod 时工作
- html - 我的 CSS 不适用于我的手机屏幕宽度
- python - 数据框列中的值不会从字符串更改为浮点数
- mysql - 如果数据库名称使用大写字母,则无法从 MySQL Workbench 创建存储过程