List of usage examples for android.webkit CookieManager removeSessionCookie
@Deprecated public abstract void removeSessionCookie();
From source file:Main.java
public static void setCookie(Context context, String url) { FileInputStream in = null;/*from www . j av a 2s . c o m*/ try { in = context.openFileInput(TAXICOOKIE_FILE); } catch (FileNotFoundException e) { e.printStackTrace(); } if (in == null) { Log.w(TAG, "saveCookie: Cannot open file: " + TAXICOOKIE_FILE); } BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String cookieStr = null; try { cookieStr = reader.readLine(); reader.close(); } catch (IOException e) { e.printStackTrace(); } Log.d(TAG, "cookieStr: " + cookieStr); if (cookieStr == null) { return; } CookieSyncManager.createInstance(context); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeSessionCookie(); cookieManager.setCookie(url, cookieStr); CookieSyncManager.getInstance().sync(); }
From source file:Main.java
@SuppressWarnings("deprecation") public static void clearCookies(Context context) { if (Build.VERSION.SDK_INT >= 21) { try {/*from w w w .j a va2 s. c o m*/ CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } catch (Exception e) { } } else { try { CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context); cookieSyncMngr.startSync(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } catch (Exception e) { } } }
From source file:org.catrobat.catroid.ui.WebViewActivity.java
@SuppressWarnings("deprecated") @SuppressLint("NewApi") public static void clearCookies(Context context) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context); cookieSyncMngr.startSync();/*from w w w . j av a2 s . c o m*/ CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } else { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } }
From source file:com.jaspersoft.android.jaspermobile.cookie.LegacyCookieManager.java
@Override public void semanticConfiguration(String targetDomain) { CookieSyncManager.createInstance(getContext()); final CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeSessionCookie(); cookieManager.setCookie(targetDomain, StringUtils.join(getCookieStore(), ";")); CookieSyncManager.getInstance().sync(); }
From source file:com.kinsights.cookies.Cookies.java
public void clear() { CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeExpiredCookie(); cookieManager.removeSessionCookie(); cookieManager.removeAllCookie();//w ww. j a v a 2s . c om }
From source file:net.ecfirm.ec.ec1.net.EcNet.java
protected void setCookie() throws Exception { Cookie cookie = null;// ww w .j a v a 2 s . c o m if ((EcNetHelper.cookies != null) && (EcNetHelper.cookies.size() > 0)) cookie = EcNetHelper.cookies.get(0); CookieSyncManager.createInstance(context); CookieManager cookieManager = CookieManager.getInstance(); if (cookie != null) { cookieManager.removeSessionCookie(); String cookieStr = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain(); cookieManager.setCookie(net.getProtocol() + "://" + net.getHost(), cookieStr); CookieSyncManager.getInstance().sync(); } }
From source file:org.dmfs.oauth2.android.fragment.InteractiveGrantFragment.java
@SuppressLint("SetJavaScriptEnabled") @Nullable/* w w w . j ava 2 s . c o m*/ @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { if (mWebView == null) { // create and configure the WebView // Note using just getActivity would will leak the activity. mWebView = new WebView(getActivity().getApplicationContext()); mWebView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setOnKeyListener(this); mWebView.setWebViewClient(mGrantWebViewClient); mWebView.loadUrl(mGrant.authorizationUrl().toASCIIString()); // wipe cookies to enforce a new login if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(getActivity()); cookieSyncMngr.startSync(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } } return mWebView; }
From source file:com.microsoft.aad.adal.hello.MainActivity.java
private void clearSessionCookie() { // Webview by default does not clear session cookies even after app is // closed(Bug in Webview). // Example to clean session cookie Logger.v(TAG, "Clear session cookies"); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeSessionCookie(); CookieSyncManager.getInstance().sync(); }
From source file:com.popdeem.sdk.uikit.fragment.PDUIInstagramLoginFragment.java
@SuppressWarnings("deprecation") private void clearCookies() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else {// ww w . j a v a2s .c om CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(getActivity()); cookieSyncManager.startSync(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncManager.stopSync(); cookieSyncManager.sync(); } }
From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java
@Override public void onAccountLogoutSuccess() { LOG.debug("onAccountLogoutSuccess"); this.onAccountIsNotLoggedIn(); this.annotationsManager = null; //if current account ?? final SimplifiedCatalogAppServicesType app = Simplified.getCatalogAppServices(); app.getBooks().destroyBookStatusCache(); Simplified.getCatalogAppServices().reloadCatalog(true, this.account); final Resources rr = NullCheck.notNull(this.getResources()); final Context context = this.getApplicationContext(); final CharSequence text = NullCheck.notNull(rr.getString(R.string.settings_logout_succeeded)); final int duration = Toast.LENGTH_SHORT; final TextView bt = NullCheck.notNull(this.barcode_text); final TextView pt = NullCheck.notNull(this.pin_text); UIThread.runOnUIThread(() -> {// w w w . j ava 2 s .c om bt.setVisibility(View.GONE); pt.setVisibility(View.GONE); final Toast toast = Toast.makeText(context, text, duration); toast.show(); finish(); overridePendingTransition(0, 0); startActivity(getIntent()); overridePendingTransition(0, 0); }); // logout clever if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { final CookieSyncManager cookie_sync_manager = CookieSyncManager.createInstance(this); cookie_sync_manager.startSync(); final CookieManager cookie_manager = CookieManager.getInstance(); cookie_manager.removeAllCookie(); cookie_manager.removeSessionCookie(); cookie_sync_manager.stopSync(); cookie_sync_manager.sync(); } }