當前位置: 首頁>>代碼示例>>Java>>正文


Java WebView.clearHistory方法代碼示例

本文整理匯總了Java中android.webkit.WebView.clearHistory方法的典型用法代碼示例。如果您正苦於以下問題:Java WebView.clearHistory方法的具體用法?Java WebView.clearHistory怎麽用?Java WebView.clearHistory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.clearHistory方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clearWebViewAllCache

import android.webkit.WebView; //導入方法依賴的package包/類
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();
        }
    }
 
開發者ID:Justson,項目名稱:AgentWeb,代碼行數:20,代碼來源:AgentWebUtils.java

示例2: clearWebView

import android.webkit.WebView; //導入方法依賴的package包/類
static final void clearWebView(WebView m) {

        if (m == null)
            return;
        if (Looper.myLooper() != Looper.getMainLooper())
            return;
        m.loadUrl("about:blank");
        m.stopLoading();
        if (m.getHandler() != null)
            m.getHandler().removeCallbacksAndMessages(null);
        m.removeAllViews();
        ViewGroup mViewGroup = null;
        if ((mViewGroup = ((ViewGroup) m.getParent())) != null)
            mViewGroup.removeView(m);
        m.setWebChromeClient(null);
        m.setWebViewClient(null);
        m.setTag(null);
        m.clearHistory();
        m.destroy();
        m = null;


    }
 
開發者ID:Justson,項目名稱:AgentWeb,代碼行數:24,代碼來源:AgentWebUtils.java

示例3: onPageFinished

import android.webkit.WebView; //導入方法依賴的package包/類
/**
 * 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);

}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:31,代碼來源:SystemWebViewClient.java

示例4: onCreate

import android.webkit.WebView; //導入方法依賴的package包/類
@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);
}
 
開發者ID:googlesamples,項目名稱:android-AutofillFramework,代碼行數:23,代碼來源:WebViewSignInActivity.java

示例5: onPageFinished

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
public void onPageFinished(WebView view, String url) {
    mPagesLoaded++;
    if (mPagesLoaded == 1) {
        // Now that WebView has loaded at least one page we know it has read in the proxy
        // settings.  Now prompt the WebView read the Network-specific proxy settings.
        setWebViewProxy();
        // Load the real page.
        view.loadUrl(mURL.toString());
        return;
    } else if (mPagesLoaded == 2) {
        // Prevent going back to empty first page.
        view.clearHistory();
    }
    String code = "var form = document.getElementsByTagName('form');" +
            //"alert(document.baseURI);" +
                "if (form.length === 0) { }" +
                "else {" +
                "for (var i = 0; i < form.length; i++) {" +
                "var action = escape(form[i].action);" +
                "form[i].action = 'http://127.0.0.1:8765?android-original-action='+action;" +
                "}}";
        //Add my password and username
        /*String code = "var form = document.getElementsByTagName('form')[0];" +
        "form.user.value = 'u.name';" +
        "form.auth_user.value = '[email protected]'; " +
        "form.Realm.value = 'stud';" +
        "form.auth_pass.value = 'password';";
        */
        view.loadUrl("javascript:(function() {" + code +  "})()");
    testForCaptivePortal(true);
}
 
開發者ID:jsparber,項目名稱:CaptivePortalAutologin,代碼行數:33,代碼來源:CaptivePortalLoginActivity.java

示例6: hideVpaidNShowPlayer

import android.webkit.WebView; //導入方法依賴的package包/類
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();
        }
    }
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:12,代碼來源:MoviePlayingState.java

示例7: hideVpaidNShowPlayer

import android.webkit.WebView; //導入方法依賴的package包/類
private void hideVpaidNShowPlayer(final PlayerUIController imcontroller) {

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

        WebView vpaidEWebView = imcontroller.getVpaidWebView();
        if (vpaidEWebView != null) {
            vpaidEWebView.setVisibility(View.GONE);
            vpaidEWebView.loadUrl(VpaidClient.EMPTY_URL);
            vpaidEWebView.clearHistory();
        }
    }
 
開發者ID:Tubitv,項目名稱:TubiPlayer,代碼行數:12,代碼來源:AdPlayingState.java

示例8: clearCache

import android.webkit.WebView; //導入方法依賴的package包/類
/**
 * 清空webview緩存
 */
public static void clearCache(final IQuickFragment webLoader, final WebView wv, JSONObject param, final Callback callback) {
    wv.clearHistory();
    wv.clearCache(true);
    wv.clearFormData();
    new Thread(new Runnable() {
        @Override
        public void run() {
            FileUtil.deleteFile(new File(webLoader.getPageControl().getContext().getCacheDir().getAbsolutePath()));
            webLoader.getPageControl().getContext().deleteDatabase("webview.db");
            webLoader.getPageControl().getContext().deleteDatabase("webviewCache.db");
            callback.applySuccess();
        }
    }).start();
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:18,代碼來源:RuntimeApi.java

示例9: onDestroy

import android.webkit.WebView; //導入方法依賴的package包/類
/** Called when the activity is finally destroyed or in portrait-landscape switch. */
  @Override
  public void onDestroy()	{
// mhistoricalRecMgr.flush();	// shouldn't be done here because onDestroy is not called when switch to home screen and put smartmath background.

  	// release memory of wvOutput.
  	WebView wvOutput = (WebView) findViewById(R.id.webviewSmartMathOutput);
  	if (wvOutput != null)	{
	ViewGroup viewGroup = (ViewGroup) wvOutput.getParent();
	if (viewGroup != null)
	{
		viewGroup.removeView(wvOutput);
	}
	wvOutput.setFocusable(true);
	wvOutput.removeAllViews();
	wvOutput.clearHistory();
	wvOutput.destroy();
  	}
  	if (isFinishing())	{
  		MFPAdapter.clear();
  	}
  	try	{
  		super.onDestroy();
  	} catch(Exception e)	{
  		// have to add this for Amazon because at com.amazon.android.Kiwi.onDestroy(Unknown Source) it may throw exceptions.
  	}
  	if (isFinishing())	{
  		System.exit(0);	// clear memory so that if adView get problem, it can really restart.
  	}
  }
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:31,代碼來源:ActivitySmartCalc.java

示例10: onCreate

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceBundle) {
    super.onCreate(savedInstanceBundle);

    setContentView(R.layout.li_login_activity);
    Intent intent = getIntent();
    Toolbar toolbar = (Toolbar) findViewById(R.id.li_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    service = new LiAuthServiceImpl(this);

    webViewOauth = (WebView) findViewById(R.id.li_web_oauth);
    progBar = (ProgressBar) findViewById(R.id.li_login_page_prog_bar);
    loginInProgTxt = (TextView) findViewById(R.id.li_login_in_prog_txt);
    String authUrl = intent.getData().toString();
    progBar.setVisibility(View.VISIBLE);
    webViewOauth.setVisibility(View.INVISIBLE);
    loginInProgTxt.setText(getString(R.string.li_openingLoginPage));
    loginInProgTxt.setVisibility(View.VISIBLE);
    isAccessTokenSaved = false;
    webViewOauth.clearHistory();
    webViewOauth.clearFormData();
    webViewOauth.clearCache(true);
    setTitle(authUrl);
    //set the web client
    webViewOauth.setWebViewClient(new LoginWebViewClient());
    webViewOauth.setWebChromeClient(new LoginWebChromeClient());
    //activates JavaScript (just in case)
    WebSettings webSettings = webViewOauth.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setAppCacheEnabled(false);
    //load the url of the oAuth login page
    webViewOauth.loadUrl(authUrl);
}
 
開發者ID:lithiumtech,項目名稱:li-android-sdk-core,代碼行數:36,代碼來源:LiLoginActivity.java

示例11: onCreateView

import android.webkit.WebView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    fragmentView = inflater.inflate(R.layout.fragment_portal, container, false);
    final WebView webview = (WebView) fragmentView.findViewById(R.id.webview);
    webview.setWebViewClient(new WebViewClient());
    webview.clearCache(true);
    webview.clearHistory();
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    String account = Model.getInstance().getAccount();
    String password = Model.getInstance().getPassword();
    webview.setOnKeyListener(new View.OnKeyListener(){

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK
                    && event.getAction() == MotionEvent.ACTION_UP
                    && webview.canGoBack()) {
                webview.goBack();
                return true;
            }

            return false;
        }

    });
    if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(password)) {
        mProgressDialog = ProgressDialog.show(this.getContext(), null,
                getString(R.string.nportal_loggingin));
        Thread loginThread = new Thread(new LoginNportalRunnable(account, password,
                new LoginHandler(this)));
        loginThread.start();
    }

    return fragmentView;
}
 
開發者ID:kamisakihideyoshi,項目名稱:TaipeiTechRefined,代碼行數:38,代碼來源:PortalFragment.java

示例12: closeApp

import android.webkit.WebView; //導入方法依賴的package包/類
public static void closeApp (final Activity activity, WebView webView) {

        sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
        sharedPref.edit().putString("started", "").apply();
        sharedPref.edit().putInt("closeApp", 1).apply();

        if (sharedPref.getBoolean ("clearCookies", false)){
            CookieManager cookieManager = CookieManager.getInstance();
            cookieManager.removeAllCookies(null);
            cookieManager.flush();
        }

        if (sharedPref.getBoolean ("clearCache", false)){
            webView.clearCache(true);
        }

        if (sharedPref.getBoolean ("clearForm", false)){
            webView.clearFormData();
        }

        if (sharedPref.getBoolean ("history", false)){
            activity.deleteDatabase("history_DB_v01.db");
            webView.clearHistory();
        }

        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                activity.finish();
            }
        }, 500);
    }
 
開發者ID:JaeNuguid,項目名稱:Kids-Portal-Android,代碼行數:34,代碼來源:helper_main.java

示例13: onPageFinished

import android.webkit.WebView; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:59,代碼來源:CordovaWebViewClient.java


注:本文中的android.webkit.WebView.clearHistory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。