https://blog.csdn.net/t12x3456/article/details/39134961
private ArrayList<String> loadHistoryUrls = new ArrayList<String>();
loadHistoryUrls.add(首页url);
private void gobackOrExist() {
WebBackForwardList mWebBackForwardList = myWebView.copyBackForwardList();
for (int i = 0; i < mWebBackForwardList.getSize(); i++) {
LogUtil.e("backs-list-chain", mWebBackForwardList.getCurrentItem().getOriginalUrl() + ": " + mWebBackForwardList.getCurrentItem().getUrl());
}
if (myWebView.canGoBack()) {
if (loadHistoryUrls.size() > 2 && loadHistoryUrls.get(loadHistoryUrls.size() - 1).contains("_paramed")) {
loadHistoryUrls.remove(loadHistoryUrls.get(loadHistoryUrls.size() - 1));
loadHistoryUrls.remove(loadHistoryUrls.get(loadHistoryUrls.size() - 1));
myWebView.loadUrl(loadHistoryUrls.get(loadHistoryUrls.size() - 1));
}else if (loadHistoryUrls.size() ==1){
AppManager.getAppManager().finishActivity(WebViewActivity.this);
}else{
myWebView.goBack();
}
} else {
AppManager.getAppManager().finishActivity(WebViewActivity.this);
}
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//加载所有带重定向的url 会调用两次。
loadHistoryUrls.add(url);
Log
1:首页
2019-06-19 17:42:04.562 5979-5979/com.sh.android.EGold.activity E/go-crrt-url-started:
2019-06-19 17:42:06.555 5979-5979/com.sh.android.EGold.activity E/go-crrt-url-finished:
2019-06-19 17:42:10.007 5979-5979/com.sh.android.EGold.activity E/go-crrt-url-loading:
2带重定向的url
https://b.pingan.com.cn/app_com/authsdk/m/login/pages/login.html?channel=BROP-MOP&config=eyJjZmJEYXRhIjp7fSwiaGVhZCI6eyJzaG93Ijp0cnVlfSwidXNlcm5hbWUiOnt9LCJidXR0b25UZXh0IjoiXHU3NjdiXHU1ZjU1IiwibGlua3MiOiIxMSIsInBhdHRlcnMiOnt9LCJyZWZlcmVlIjpmYWxzZSwiYmluZFdlQ2hhdCI6eyJlbmFibGUiOmZhbHNlfSwidW5iaW5kV2VDaGF0Ijp7ImVuYWJsZSI6ZmFsc2V9LCJzb3VyY2VQYXJhbXMiOnsiYWYiOiJtX1MwTWhjMnRjQTYyT0N4T1UzMjk3IiwiYWkiOiJWMzM4MCJ9LCJ0b2JsYW5rIjoiMSJ9&replace=0
2019-06-19 17:42:10.013 5979-5979/com.sh.android.EGold.activity E/go-crrt-url-started: https://b.pingan.com.cn/app_com/authsdk/m/login/pages/login.html?channel=BROP-MOP&config=eyJjZmJEYXRhIjp7fSwiaGVhZCI6eyJzaG93Ijp0cnVlfSwidXNlcm5hbWUiOnt9LCJidXR0b25UZXh0IjoiXHU3NjdiXHU1ZjU1IiwibGlua3MiOiIxMSIsInBhdHRlcnMiOnt9LCJyZWZlcmVlIjpmYWxzZSwiYmluZFdlQ2hhdCI6eyJlbmFibGUiOmZhbHNlfSwidW5iaW5kV2VDaGF0Ijp7ImVuYWJsZSI6ZmFsc2V9LCJzb3VyY2VQYXJhbXMiOnsiYWYiOiJtX1MwTWhjMnRjQTYyT0N4T1UzMjk3IiwiYWkiOiJWMzM4MCJ9LCJ0b2JsYW5rIjoiMSJ9&replace=0
3重定向的url 一共两次/go-crrt-url-loading:
2019-06-19 17:42:10.111 5979-5979/com.sh.android.EGold.activity E/go-crrt-url-loading: https://b.pingan.com.cn/app_com/authsdk/m/login/pages/login.html?paramed
2019-06-19 17:42:10.121 5979-5979/com.sh.android.EGold.activity E/go-crrt-url-started: https://b.pingan.com.cn/app_com/authsdk/m/login/pages/login.html?paramed
2019-06-19 17:42:10.860 5979-5979/com.sh.android.EGold.activity E/go-crrt-url-finished: https://b.pingan.com.cn/app_com/authsdk/m/login/pages/login.html?paramed