@Override protected void onResume() { super.onResume(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { CookieManager cm = CookieManager.getInstance(); cm.flush(); } else { CookieSyncManager.getInstance().startSync(); } }
@Override protected void onPause() { super.onPause(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { CookieManager cm = CookieManager.getInstance(); cm.flush(); } else { CookieSyncManager.getInstance().startSync(); } }
@Nullable @Override @SuppressWarnings("deprecation") @SuppressLint("SetJavaScriptEnabled") public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Context context = getContext2(); AssertUtils.assertNotNull(context); EhUtils.signOut(context); // http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception CookieManager cookieManager = CookieManager.getInstance(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { cookieManager.flush(); cookieManager.removeAllCookies(null); cookieManager.removeSessionCookies(null); } else { CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(context); cookieSyncManager.startSync(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncManager.stopSync(); } mWebView = new WebView(context); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(new LoginWebViewClient()); mWebView.loadUrl(EhUrl.URL_SIGN_IN); return mWebView; }
} else { CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(this); cookieSyncManager.startSync(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie();
cm.flush(); } else { CookieSyncManager.getInstance().startSync();
@Override protected void onResume() { if (implementation != null) { WebviewUtil.onResume(implementation.getWebView()); } CookieSyncManager csm = CookieSyncManager.getInstance(); if (csm != null) csm.startSync(); super.onResume(); }
/** * {@inheritDoc} */ @Override public void onResume() { super.onResume(); // Pass lifecycle events to the WebView mWebView.onResume(); // Start synchronizing the CookieSyncManager mCookieSyncManager.startSync(); // Set the cache mode depending on connection type and availability updateCacheMode(); // Register a Connectivity action receiver so that we can update the cache mode accordingly registerReceiver(mConnectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); // Horrible lifecycle hack if (mCreatingActivity) { mCreatingActivity = false; return; } // Resume this activity properly, reload preferences, etc. onResumeActivity(); }
@Override protected void onCreate(Bundle b) { super.onCreate(b); String activityType = getIntent(). getStringExtra(INTENT_KEY_ACTIVITY_TYPE); if (StringUtil.isEmpty(activityType)) { Clog.e(Clog.baseLogTag, Clog.getString(R.string.adactivity_no_type)); finish(); } else if (ACTIVITY_TYPE_INTERSTITIAL.equals(activityType)) { implementation = new InterstitialAdActivity(this); implementation.create(); } else if (ACTIVITY_TYPE_BROWSER.equals(activityType)) { implementation = new BrowserAdActivity(this); implementation.create(); } else if (ACTIVITY_TYPE_MRAID.equals(activityType)) { implementation = new MRAIDAdActivity(this); implementation.create(); } CookieSyncManager.createInstance(this); CookieSyncManager csm = CookieSyncManager.getInstance(); if (csm != null) csm.startSync(); }
/** * dammit, android. stolen from: * https://stackoverflow.com/questions/28998241/how-to-clear-cookies-and-cache-of-webview-on-android-when-not-in-webview */ @SuppressWarnings("deprecation") protected void clearCookies(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { CookieSyncManager cookieSyncMngr=CookieSyncManager.createInstance(context); cookieSyncMngr.startSync(); CookieManager cookieManager=CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } } }
/** * Clear the cookies */ @SuppressWarnings("deprecation") public void clearCookies() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(getContext()); cookieSyncMngr.startSync(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } }