search

Home  >  Q&A  >  body text

android - WebView加载天猫等购物网页出问题?

用WebView加载淘宝等一些购物网站时,可以链接到首页,但从首页再点击进入详情页就无法加载,该怎么解决?

巴扎黑巴扎黑2773 days ago705

reply all(4)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 18:02:58

    Thank you for your answers. It has been solved now, but I still don’t understand the principle. I hope someone can explain the reason.
    This method was set up before, but the display is outdated and some shopping websites such as Taobao and Tmall cannot be loaded correctly:

    webView.setWebViewClient(new WebViewClient(){
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    view.loadUrl(url);
                    return true;
                }
            });

    It will be ok if I switch to another method of overloading later, but I still hope someone can explain why?

    @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                view.loadUrl(request.toString());
                return true;
            }

    You can also directly copy the following method

     @Override
           public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
               handler.proceed();
           }

    I found an article explaining WebView in detail

    reply
    0
  • PHPz

    PHPz2017-04-17 18:02:58

    It should be that webview cannot recognize tmall at the beginning of the URL. You can try replacing it with https every time webview loads

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 18:02:58

    This tamll is used to wake up the Tmall APP on the mobile phone. Because the default webview does not support waking up any app, an error will occur.

    If you want to open Tmall or Taobao on the current page
    , you need to re-parse its link. You can see that the url of the actual product is "url?=" after the question mark. You can parse the value of the url and open it by calling webview. This is modified in the same place as wake-up, both in shouldOverrideUrlLoading. The loaded url here determines whether it starts with tmall. If it does, parse it. If not, determine whether it starts with http or https, and then load it

    You can read this article. I have done a wake-up call but can’t find the code.

    http://www.jianshu.com/p/fd04...

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 18:02:58

    tmall:// This is the jump schema protocol dedicated to Tmall app. You definitely cannot open it in webview.

    If you have the Tmall app client installed on your phone, you can automatically wake up the app to open the page

    reply
    0
  • Cancelreply