首页 > 解决方案 > 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

enter image description here

and while clicking that button rather then opining play store app webview is redirecting to a web url which is not found.

enter image description here

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.

标签: androidandroid-intentwebviewandroid-webviewgoogle-play-console

解决方案


您需要覆盖shouldOverrideUrlLoading,但您还必须检查 URL,如果它以intent://方案开头,则有条件地创建一个意图。我们(Android WebView 团队)已经编写了一个示例应用程序来实现这一点。


推荐阅读