Dead loop in android webview backkey for redirect href link

后端 未结 4 2290
挽巷
挽巷 2021-02-14 10:30

I got to a dead loop in Android webview application with backkey while dealing with redirect links.

For example, when my webview started, it goes to link0.

In l

4条回答
  •  猫巷女王i
    2021-02-14 11:35

    shouldOverrideUrlLoading() is called on a per-URL basis. So, if http://site1.com/ redirects to http://site2.com/, which then redirects to http://site3.com/, you are calling WebView.loadUrl() for each of these URL's. Thus each appears in the back stack.

    Instead of creating a WebViewClient you probably want a WebChromeClient. WebChromeClient defines a method onCreateWindow that is only invoked when the WebView is trying to create a new window, not for every single URL it accesses.

提交回复
热议问题