Sync cookie with system browser. - Android Network

Android examples for Network:Cookie

Description

Sync cookie with system browser.

Demo Code


//package com.java2s;

import android.content.Context;
import android.os.Build;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;

public class Main {
    /**/*from  www.j a v a 2 s . c  om*/
     * Sync cookie with system browser.
     *
     * @param context
     *     the context
     */
    public static void syncCookieWithSystemBrowser(Context context) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            CookieManager.getInstance().flush();
        } else {
            CookieSyncManager.createInstance(context);
            CookieSyncManager.getInstance().startSync();
            CookieSyncManager.getInstance().sync();
        }
    }
}

Related Tutorials