Home > Mobile >  Huawei mobile phone android webview millet click return path loss, oppo normal, how to solve
Huawei mobile phone android webview millet click return path loss, oppo normal, how to solve

Time:11-26

Huawei, millet I check back in the right path, and then click the jump page tip 403 Forbidden

The wrong return


The correct return


The great spirit guide, really don't know where is the problem

CodePudding user response:

OnPageFinished inside what is a record of each hop your url value

Public void onPageFinished (WebView view, String url) {

RecordUrl (view. GetOriginalUrl ());
//recordUrl (the getUrl ()); GetOriginalUrl getUrl and see the difference between

Super. OnPageFinished (view, url);


}


/* *
* record the redirect links to avoid repetition in the refresh the page into the stack */
Private void recordUrl (String url)
{
//here can also according to their own business to block some links in the URL stack when the return key to remove the last
if(! TextUtils. IsEmpty (url) & amp; & ! Url. EqualsIgnoreCase (getLastPageUrl ()) & amp; & ! Url. The contains (" CasServer/login ")) {
MUrls. Push (url);
}

}

/* * get back links */
Private synchronized String getLastPageUrl () {
Return mUrls. The size () & gt; 0? MUrls. Peek () : null;
}

/launch back link * * *
Public String popLastPageUrl () {
If (mUrls. The size () & gt;
=2){
MUrls. Pop ();//pop the current page url
Return mUrls. Pop ();
}
Return null;
}

CodePudding user response:

/* *
* record the URL stack
* rules:
* 1. Not in {@ code WebView. OnPageFinished (); } began to record the URL
* 2. Records need shielding redirect URL
* */
Public Stack MUrls=new Stack<> (a);



According to my this method records every time you jump and web url. Goback () what's the difference between a url, redirect, or other problems the debug mUrl parameters just see the problem, really look not to come out, then use this method directly record every url of your back operation directly write

 String lastPageUrl=webView. PopLastPageUrl (); 
If (lastPageUrl==null) {
Super. GoBack (view);
} else {
WebView. LoadUrl (lastPageUrl);
RelativeClose. SetVisibility (the VISIBLE);
}
  • Related