android webview onpagefinished调用两次,但shouldOverrideUrlLoading只调用一次

时间:2017-06-29 12:24:18

标签: android webview

我在android webview中加载url发现onpagefinished()调用了两次但是shouldOverrideUrlLoading只调用了一次。

网址连接到网上付款后,第一次加载的网址已添加了参数,如'#!cardIndex?r = 0.8913584462445969',那么我无法返回上一页。

发生了什么,我怎么能解决这个问题。

@Override
public void onPageFinished(String url) {
    mNavView.setWebTitle();
    if (!mIsLoadFailed) {
        mLastLoadSuccessIndex = getCurrentWebHistoryItemIndex();
    if(url.contains("95516")&&url.contains("?r=")){
            mLastLoadSuccessIndex = mLastLoadSuccessIndex-2 ;  
            VLog.e(TAG,mLastLoadSuccessIndex+"---------"+url);
      }
    }}

   private class HtmlWebClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

        VLog.d(TAG, "shouldOverrideUrlLoading, url = " + url);

        if (TextUtils.isEmpty(url)) {
            return true;
        }

        if (url.startsWith("mailto:")) { //屏蔽邮箱
            return true;
        }

0 个答案:

没有答案