android.webkit.WebView#clearHistory ( )源码实例Demo

下面列出了android.webkit.WebView#clearHistory ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BigDataPlatform   文件: SystemWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
源代码2 项目: xmall   文件: SystemWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
源代码3 项目: sealrtc-android   文件: CallActivity.java
public void destroyWebView(WebView mWebView) {
    if (mWebView != null) {
        try {
            ViewParent parent = mWebView.getParent();
            if (parent != null) {
                ((ViewGroup) parent).removeView(mWebView);
            }
            mWebView.stopLoading();
            mWebView.getSettings().setJavaScriptEnabled(false);
            mWebView.clearHistory();
            mWebView.clearView();
            mWebView.removeAllViews();

            mWebView.destroy();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
源代码6 项目: AgentWeb   文件: AgentWebUtils.java
static void clearWebViewAllCache(Context context, WebView webView) {
	try {
		AgentWebConfig.removeAllCookies(null);
		webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
		context.deleteDatabase("webviewCache.db");
		context.deleteDatabase("webview.db");
		webView.clearCache(true);
		webView.clearHistory();
		webView.clearFormData();
		clearCacheFolder(new File(AgentWebConfig.getCachePath(context)), 0);

	} catch (Exception ignore) {
		//ignore.printStackTrace();
		if (AgentWebConfig.DEBUG) {
			ignore.printStackTrace();
		}
	}
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.login_webview_activity);

    WebView webView = findViewById(R.id.webview);
    WebSettings webSettings = webView.getSettings();
    webView.setWebViewClient(new WebViewClient());
    webSettings.setJavaScriptEnabled(true);

    String url = getIntent().getStringExtra("url");
    if (url == null) {
        url = "file:///android_res/raw/sample_form.html";
    }
    if (DEBUG) Log.d(TAG, "Clearing WebView data");
    webView.clearHistory();
    webView.clearFormData();
    webView.clearCache(true);
    Log.i(TAG, "Loading URL " + url);
    webView.loadUrl(url);
}
 
源代码8 项目: chappiecast   文件: SystemWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
源代码9 项目: countly-sdk-cordova   文件: SystemWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
源代码10 项目: keemob   文件: SystemWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
源代码11 项目: app-icon   文件: SystemWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }
    parentEngine.client.onPageFinishedLoading(url);

}
 
源代码13 项目: 4pdaClient-plus   文件: ThemeFragment.java
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    if (startsWith(url, mUrl) && !mLoadingFinished) {
        mLoadingFinished = true;
        view.removeCallbacks(mPageLoadingTimeoutHandlerTask);
        mOnErrorUrl = null;
        mUrl = null;
    } else if (mUrl == null) {
        view.setWebViewClient(getWebViewClient());
        mLoadingFinished = true;
    }
    view.clearHistory();
    //tryScrollToElement();
}
 
源代码14 项目: TubiPlayer   文件: MoviePlayingState.java
private void hideVpaidNShowPlayer(final PlayerUIController controller) {

        controller.getExoPlayerView().setVisibility(View.VISIBLE);

        WebView vpaidEWebView = controller.getVpaidWebView();
        if (vpaidEWebView != null) {
            vpaidEWebView.setVisibility(View.GONE);
            vpaidEWebView.loadUrl(VpaidClient.EMPTY_URL);
            vpaidEWebView.clearHistory();
        }
    }
 
源代码15 项目: reader   文件: CordovaWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls.
    if (!isCurrentlyLoading) {
        return;
    }
    isCurrentlyLoading = false;
    LOG.d(TAG, "onPageFinished(" + url + ")");

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageFinished", url);

    // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
    if (this.appView.getVisibility() == View.INVISIBLE) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    cordova.getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            appView.postMessage("spinner", "stop");
                        }
                    });
                } catch (InterruptedException e) {
                }
            }
        });
        t.start();
    }

    // Shutdown if blank loaded
    if (url.equals("about:blank")) {
        appView.postMessage("exit", null);
    }
}
 
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls.
    if (!isCurrentlyLoading) {
        return;
    }
    isCurrentlyLoading = false;
    LOG.d(TAG, "onPageFinished(" + url + ")");

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageFinished", url);

    // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
    if (this.appView.getVisibility() == View.INVISIBLE) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    cordova.getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            appView.postMessage("spinner", "stop");
                        }
                    });
                } catch (InterruptedException e) {
                }
            }
        });
        t.start();
    }

    // Shutdown if blank loaded
    if (url.equals("about:blank")) {
        appView.postMessage("exit", null);
    }
}
 
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    LOG.d(TAG, "onPageFinished(" + url + ")");

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageFinished", url);

    // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
    if (this.appView.getVisibility() == View.INVISIBLE) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    cordova.getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            appView.postMessage("spinner", "stop");
                        }
                    });
                } catch (InterruptedException e) {
                }
            }
        });
        t.start();
    }

    // Shutdown if blank loaded
    if (url.equals("about:blank")) {
        appView.postMessage("exit", null);
    }
}
 
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls, if url is not about:blank (CB-8317).
    if (!isCurrentlyLoading && !url.startsWith("about:")) {
        return;
    }
    isCurrentlyLoading = false;
    LOG.d(TAG, "onPageFinished(" + url + ")");

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageFinished", url);

    // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
    if (this.appView.getVisibility() == View.INVISIBLE) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    cordova.getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            appView.postMessage("spinner", "stop");
                        }
                    });
                } catch (InterruptedException e) {
                }
            }
        });
        t.start();
    }

    // Shutdown if blank loaded
    if (url.equals("about:blank")) {
        appView.postMessage("exit", null);
    }
}
 
源代码19 项目: reader   文件: CordovaWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls.
    if (!isCurrentlyLoading) {
        return;
    }
    isCurrentlyLoading = false;
    LOG.d(TAG, "onPageFinished(" + url + ")");

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageFinished", url);

    // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
    if (this.appView.getVisibility() == View.INVISIBLE) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    cordova.getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            appView.postMessage("spinner", "stop");
                        }
                    });
                } catch (InterruptedException e) {
                }
            }
        });
        t.start();
    }

    // Shutdown if blank loaded
    if (url.equals("about:blank")) {
        appView.postMessage("exit", null);
    }
}
 
源代码20 项目: IoTgo_Android_App   文件: CordovaWebViewClient.java
/**
 * Notify the host application that a page has finished loading.
 * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 *
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    // Ignore excessive calls.
    if (!isCurrentlyLoading) {
        return;
    }
    isCurrentlyLoading = false;
    LOG.d(TAG, "onPageFinished(" + url + ")");

    /**
     * Because of a timing issue we need to clear this history in onPageFinished as well as
     * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
     * true. You see when you load a url with a # in it which is common in jQuery applications
     * onPageStared is not called. Clearing the history at that point would break jQuery apps.
     */
    if (this.doClearHistory) {
        view.clearHistory();
        this.doClearHistory = false;
    }

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageFinished", url);

    // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
    if (this.appView.getVisibility() == View.INVISIBLE) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    cordova.getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            appView.postMessage("spinner", "stop");
                        }
                    });
                } catch (InterruptedException e) {
                }
            }
        });
        t.start();
    }

    // Shutdown if blank loaded
    if (url.equals("about:blank")) {
        appView.postMessage("exit", null);
    }
}