當前位置: 首頁>>代碼示例>>Java>>正文


Java CookieSyncManager.sync方法代碼示例

本文整理匯總了Java中android.webkit.CookieSyncManager.sync方法的典型用法代碼示例。如果您正苦於以下問題:Java CookieSyncManager.sync方法的具體用法?Java CookieSyncManager.sync怎麽用?Java CookieSyncManager.sync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.CookieSyncManager的用法示例。


在下文中一共展示了CookieSyncManager.sync方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clearCookiesForDomain

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
private static void clearCookiesForDomain(Context context, String domain) {
    // This is to work around a bug where CookieManager may fail to instantiate if CookieSyncManager
    // has never been created.
    CookieSyncManager syncManager = CookieSyncManager.createInstance(context);
    syncManager.sync();

    CookieManager cookieManager = CookieManager.getInstance();

    String cookies = cookieManager.getCookie(domain);
    if (cookies == null) {
        return;
    }

    String[] splitCookies = cookies.split(";");
    for (String cookie : splitCookies) {
        String[] cookieParts = cookie.split("=");
        if (cookieParts.length > 0) {
            String newCookie = cookieParts[0].trim() + "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;";
            cookieManager.setCookie(domain, newCookie);
        }
    }
    cookieManager.removeExpiredCookie();
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:24,代碼來源:Utility.java

示例2: clearCookiesForDomain

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
private static void clearCookiesForDomain(Context context, String domain) {
    // This is to work around a bug where CookieManager may fail to instantiate if
    // CookieSyncManager has never been created.
    CookieSyncManager syncManager = CookieSyncManager.createInstance(context);
    syncManager.sync();

    CookieManager cookieManager = CookieManager.getInstance();

    String cookies = cookieManager.getCookie(domain);
    if (cookies == null) {
        return;
    }

    String[] splitCookies = cookies.split(";");
    for (String cookie : splitCookies) {
        String[] cookieParts = cookie.split("=");
        if (cookieParts.length > 0) {
            String newCookie = cookieParts[0].trim() +
                    "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;";
            cookieManager.setCookie(domain, newCookie);
        }
    }
    cookieManager.removeExpiredCookie();
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:25,代碼來源:Utility.java

示例3: clearCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
/**
 * 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();
    }
}
 
開發者ID:vic797,項目名稱:prowebview,代碼行數:19,代碼來源:ProWebView.java

示例4: logout

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
/**
 * Flushes auth state when a call to logout is made.
 *
 * @param context {@link Context}
 */
public void logout(Context context) {
    this.removeFromSecuredPreferences(context, LI_DEFAULT_SDK_SETTINGS);
    this.removeFromSecuredPreferences(context, LI_AUTH_STATE);
    this.removeFromSecuredPreferences(context, LI_DEVICE_ID);
    this.removeFromSecuredPreferences(context, LI_RECEIVER_DEVICE_ID);
    this.removeFromSecuredPreferences(context, LiCoreSDKConstants.LI_SHARED_PREFERENCES_NAME);
    // For clearing cookies, if the android OS is Lollipop (5.0) and above use new way of using CookieManager else use the deprecate methods for older versions
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        Log.d(LiCoreSDKConstants.LI_LOG_TAG, "Using clearCookies code for API >=" + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1));
        CookieManager.getInstance().removeAllCookies(null);
        CookieManager.getInstance().flush();
    } else {
        Log.d(LiCoreSDKConstants.LI_LOG_TAG, "Using clearCookies code for API <" + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1));
        CookieSyncManager cookieSyncMngr= CookieSyncManager.createInstance(context);
        cookieSyncMngr.startSync();
        CookieManager cookieManager= CookieManager.getInstance();
        cookieManager.removeAllCookie();
        cookieManager.removeSessionCookie();
        cookieSyncMngr.stopSync();
        cookieSyncMngr.sync();
    }
    this.liAuthState = null;
}
 
開發者ID:lithiumtech,項目名稱:li-android-sdk-core,代碼行數:29,代碼來源:LiAuthManager.java

示例5: collectCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private String[] collectCookies() {
    String cookies = CookieManager.getInstance().getCookie(Endpoints.BASE_URL);

    if (cookies == null || cookies.isEmpty()) {
        return null;
    }
    //See: http://stackoverflow.com/questions/28998241/how-to-clear-cookies-and-cache-of-webview-on-android-when-not-in-webview
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        CookieManager.getInstance().removeAllCookies(null);
        CookieManager.getInstance().flush();
    } else {
        CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(getActivity().getApplicationContext());
        cookieSyncMngr.startSync();
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.removeAllCookie();
        cookieManager.removeSessionCookie();
        cookieSyncMngr.stopSync();
        cookieSyncMngr.sync();
    }

    return cookies.split(" ");
}
 
開發者ID:jam01,項目名稱:LittleLight,代碼行數:24,代碼來源:SignInFragment.java

示例6: clearCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
    public static void clearCookies(Context context) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            //Log.d(C.TAG, "Using clearCookies code for API >=" + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1));
            CookieManager.getInstance().removeAllCookies(null);
            CookieManager.getInstance().flush();
        } else {
//            Log.d(C.TAG, "Using clearCookies code for API <" + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1));
            CookieSyncManager cookieSyncMngr=CookieSyncManager.createInstance(context);
            cookieSyncMngr.startSync();
            CookieManager cookieManager=CookieManager.getInstance();
            cookieManager.removeAllCookie();
            cookieManager.removeSessionCookie();
            cookieSyncMngr.stopSync();
            cookieSyncMngr.sync();
        }
    }
 
開發者ID:boybeak,項目名稱:DelegateAdapter,代碼行數:19,代碼來源:Cookies.java

示例7: clearCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
/**
 * Clear cookies
 * @param context context
 */
@SuppressWarnings("deprecation")
public static 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();
    }
}
 
開發者ID:PGMacDesign,項目名稱:PGMacTips,代碼行數:23,代碼來源:MiscUtilities.java

示例8: setWebKitCookieManagerSync

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void setWebKitCookieManagerSync(final String cookie_domain_key) throws Exception {
    loadAllFromPersistence();
    CookieManager cookiemanager = CookieManager.getInstance();
    cookiemanager.setAcceptCookie(true);
    List<HttpCookie> cookies = getCookiesForUrl(new URI(cookie_domain_key));
    //URI match = new URI(cookie_domain_key);
    Log.d(TAG, "found valid cookies: " + cookies.size() + " for " + cookie_domain_key);
    if (cookies.size() > 0) {
        CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(context);
        // for (HttpCookie h : cookies) {
        /**
         * this should be only loop once.
         */
        //   cookiemanager.setCookie(cookie_domain_key, cookieValBuilder(h));
        //   break;
        // }
        cookiemanager.setCookie(cookie_domain_key, cookieValBuilder(cookies.get(0)));
        cookieSyncManager.sync();
    }

}
 
開發者ID:jjhesk,項目名稱:slideSelectionList,代碼行數:23,代碼來源:PersistentCookieStore.java

示例9: doLogin

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
private LoginResponse doLogin(String email, String password) {
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
    CookieSyncManager syncManager = CookieSyncManager.createInstance(this);
    syncManager.sync();

    LoginResponse state = netflixClient.login(email, password);

    if (state.isSuccessful()) {
        List<Cookie> cookies = netflixClient.getCookieStore().getCookies();

        for (Cookie cookie : cookies) {
            String cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain();
            cookieManager.setCookie(".netflix.com", cookieString);
            syncManager.sync();
        }
        return state;
    } else {
        return state;
    }
}
 
開發者ID:pellcorp,項目名稱:netflixbmc,代碼行數:22,代碼來源:NetflixWebViewActivity.java

示例10: clearCookie

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private void clearCookie() {
    CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(getContext());
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    cookieManager.removeSessionCookie();
    cookieManager.removeAllCookie();
    cookieSyncManager.sync();
}
 
開發者ID:TakWolf,項目名稱:CNode-OAuth-Login-Android,代碼行數:10,代碼來源:CNodeOAuthLoginView.java

示例11: clearCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public 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();
    }
}
 
開發者ID:mgilangjanuar,項目名稱:GoSCELE,代碼行數:16,代碼來源:BrowserPresenter.java

示例12: clearCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
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(this);
        cookieSyncMngr.startSync();
        CookieManager cookieManager= CookieManager.getInstance();
        cookieManager.removeAllCookie();
        cookieManager.removeSessionCookie();
        cookieSyncMngr.stopSync();
        cookieSyncMngr.sync();
    }
}
 
開發者ID:UTN-FRBA-Mobile,項目名稱:Clases-2017c1,代碼行數:16,代碼來源:OAuthActivity.java

示例13: setUserCookie

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
public void setUserCookie(String cookie) {
	CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(activity);
	cookieSyncManager.sync();
	CookieManager cookieManager = CookieManager.getInstance();
	cookieManager.setCookie(Constants.urlHost, cookie);
	CookieSyncManager.getInstance().sync();

}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:9,代碼來源:WebViewFun.java

示例14: setGameTokenCookie

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
public static void setGameTokenCookie(Context context, String token) {
    CookieSyncManager syncManger = CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    cookieManager.setCookie("http://api.game.letvstore.com", "sso_tk=" + token);
    syncManger.sync();
    LogInfo.log("wlx", "game cookie =  " + cookieManager.getCookie("http://api.game.letvstore.com"));
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:SyncUserStateUtil.java

示例15: setCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
public static void setCookies(Context context, String url) {
    String cookie1 = "letvclient_sig=" + MD5.toMd5(Global.DEVICEID + LetvConstant.MIYUE_ATTENDANCE);
    String cookie2 = "letvclient_did=" + Global.DEVICEID;
    CookieSyncManager syncManger = CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    String CookieStr = cookieManager.getCookie(url);
    if (CookieStr == null || !CookieStr.contains("letvclient_did") || !CookieStr.contains("letvclient_sig")) {
        cookieManager.setAcceptCookie(true);
        cookieManager.setCookie(url, cookie1);
        cookieManager.setCookie(url, cookie2);
        syncManger.sync();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:14,代碼來源:LetvUtils.java


注:本文中的android.webkit.CookieSyncManager.sync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。