当前位置: 首页>>代码示例>>Java>>正文


Java WebView.clearCache方法代码示例

本文整理汇总了Java中android.webkit.WebView.clearCache方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.clearCache方法的具体用法?Java WebView.clearCache怎么用?Java WebView.clearCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.clearCache方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
/**
 * Called when the application is starting, before any activity, service,
 * or receiver objects (excluding content providers) have been created.
 * Implementations should be as quick as possible (for example using
 * lazy initialization of state) since the time spent in this function
 * directly impacts the performance of starting the first activity,
 * service, or receiver in a process.
 * If you override this method, be sure to call super.onCreate().
 */
@Override
public void onCreate() {
    super.onCreate();


    // Clear WebView Cache when needed
    WebView obj = new WebView(this);
    obj.clearCache(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && BuildConfig.DEBUG) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    /**
     * Initialise prebid for DFP ad unit
     */
    initialisePrebidForDFP();
}
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:27,代码来源:PrebidApplication.java

示例3: 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

示例4: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_portal);
    mToolbar = (Toolbar) findViewById(R.id.main_toolbar);
    setSupportActionBar(mToolbar);
    setActionBar();
    WebView webview = (WebView) 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();
    if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(password)) {
        mProgressDialog = ProgressDialog.show(this, null,
                getString(R.string.nportal_loggingin));
        Thread loginThread = new Thread(new LoginNportalRunnable(account, password,
                new LoginHandler(this)));
        loginThread.start();
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:24,代码来源:PortalActivity.java

示例5: createWebView

import android.webkit.WebView; //导入方法依赖的package包/类
private void createWebView() {
    myWebView = (WebView) findViewById(R.id.webview);
    myWebView.clearCache(true);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebViewClient = new MyWebViewClient();
    myWebView.setWebViewClient(mWebViewClient);
    myWebView.setWebChromeClient(new MyWebChromeClient());
    // Start initial page load so WebView finishes loading proxy settings.
    // Actual load of mUrl is initiated by MyWebViewClient.
}
 
开发者ID:jsparber,项目名称:CaptivePortalAutologin,代码行数:12,代码来源:CaptivePortalLoginActivity.java

示例6: onCreate

import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    WebView webview = (WebView) findViewById(R.id.vkontakteview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.clearCache(true);

    //Чтобы получать уведомления об окончании загрузки страницы
    webview.setWebViewClient(new VkontakteWebViewClient());

    //otherwise CookieManager will fall with java.lang.IllegalStateException: CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()
    CookieSyncManager.createInstance(this);

    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();

    String clientId = getIntent().getStringExtra(EXTRA_CLIENT_ID);
    String scope = getIntent().getStringExtra(EXTRA_SCOPE);
    String groupIds = getIntent().getStringExtra(EXTRA_GROUP_IDS);

    String url = Auth.getUrl(clientId, scope, groupIds);
    webview.loadUrl(url);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:27,代码来源:LoginActivity.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: clearCache

import android.webkit.WebView; //导入方法依赖的package包/类
public static void clearCache(@Nullable WebView view) {
    if (view == null) return;
    view.clearCache(true);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:5,代码来源:WebUtils.java

示例12: clearCache

import android.webkit.WebView; //导入方法依赖的package包/类
private void clearCache() {
    WebView webView = new WebView(mActivity);
    webView.clearCache(true);
    webView.destroy();
    Utils.showSnackbar(mActivity, R.string.message_cache_cleared);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:7,代码来源:PrivacySettingsFragment.java


注:本文中的android.webkit.WebView.clearCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。