Solution to Android WebView redirection problem
WebView redirection is required in the project, but because there are many loading operations in a webveiw, WebView is called. When using the goback () method, the operation effect we need is often not achieved.
1. Solutions
Webbackforwardlist webbackforwardlist = WebView. Copybackforwardlist() gets the WebView loading stack, and then performs logical operations with the loading stack
2. Common methods of webbackforwardlist
GetSize () method obtains the length of the currently loaded stack;
Getcurrentitem () gets the interface loaded by the current WebView. We can get URL, title and other contents under this method;
Getcurrentindex() gets the position currently loaded in the loading stack;
Webbackforwardlist.getitematindex (index) gets the index page in the loading stack;
3. Reasonable use
In 2, we get some information about the loaded page, and then we can load the page according to the current URL, title and location. To carry out corresponding processing.
4. Demo usage
Now we have such a scenario: open an activity, load the a interface with WebView, and then click B, then click C, and then click D in a. When returning to the operation, we need to jump from D to B, and then jump to a. the following is the code:
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.