Example usage for android.webkit CookieSyncManager stopSync

List of usage examples for android.webkit CookieSyncManager stopSync

Introduction

In this page you can find the example usage for android.webkit CookieSyncManager stopSync.

Prototype

@Deprecated
public void stopSync() 

Source Link

Document

stopSync() requests sync manager to stop sync.

Usage

From source file:Main.java

@SuppressWarnings("deprecation")
public static void clearCookies(Context context) {

    if (Build.VERSION.SDK_INT >= 21) {
        try {/*w  w  w. j a  v a2 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  a v  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:org.dmfs.oauth2.android.fragment.InteractiveGrantFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Nullable//from   w  ww. j  av a2 s  .  c om
@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.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 {// www.  j ava 2  s  .co  m
        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(() -> {/*from  w  ww  .  j a  va  2 s .c o  m*/
        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();
    }
}