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


Java CookieManager.getCookie方法代碼示例

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


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

示例1: clearCookiesForDomain

import android.webkit.CookieManager; //導入方法依賴的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: getCookieFromAppCookieManager

import android.webkit.CookieManager; //導入方法依賴的package包/類
public static String getCookieFromAppCookieManager(String url) throws MalformedURLException {
    CookieManager cookieManager = CookieManager.getInstance();
    if (cookieManager == null)
        return null;
    // 出錯點 1
    cookieManager.setAcceptCookie(true);
    String rawCookieHeader = null;
    URL parsedURL = new URL(url);

    // 出錯點 2
    // Extract Set-Cookie header value from Android app CookieManager for this URL
    rawCookieHeader = cookieManager.getCookie(parsedURL.getHost());
    if (rawCookieHeader == null)
        return null;
    return rawCookieHeader;
}
 
開發者ID:kamisakihideyoshi,項目名稱:TaipeiTechRefined,代碼行數:17,代碼來源:Connector.java

示例3: clearCookiesForDomain

import android.webkit.CookieManager; //導入方法依賴的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

示例4: getExistingCookie

import android.webkit.CookieManager; //導入方法依賴的package包/類
private String getExistingCookie() {
    try {
        CookieSyncManager.createInstance(context);
        CookieManager cm = CookieManager.getInstance();
        if (cm != null) {
            String wvcookie = cm.getCookie(Settings.COOKIE_DOMAIN);
            if (!TextUtils.isEmpty(wvcookie)) {
                String[] existingCookies = wvcookie.split("; ");
                for (String cookie : existingCookies) {
                    if (cookie != null && cookie.contains(Settings.AN_UUID)) {
                        return cookie;
                    }
                }
            }
        }
    } catch (Exception e) {
    }
    return null;
}
 
開發者ID:prebid,項目名稱:prebid-mobile-android,代碼行數:20,代碼來源:ServerConnector.java

示例5: setCookies

import android.webkit.CookieManager; //導入方法依賴的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

示例6: syncCookie

import android.webkit.CookieManager; //導入方法依賴的package包/類
/**
 * 將cookie同步到WebView
 *
 * @param url    WebView要加載的url
 * @param cookie 要同步的cookie
 * @return true:同步cookie成功;false:同步cookie失敗
 */
public static boolean syncCookie(Context context, String url, String cookie) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        CookieSyncManager.createInstance(context);
    }
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setCookie(url, cookie);
    String newCookie = cookieManager.getCookie(url);
    return !TextUtils.isEmpty(newCookie);
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:17,代碼來源:CookieKeeper.java

示例7: clearCookieByUrlInternal

import android.webkit.CookieManager; //導入方法依賴的package包/類
private static void clearCookieByUrlInternal(String url, CookieManager pCookieManager) {
    if (TextUtils.isEmpty(url)) {
        return;
    }
    String cookieString = pCookieManager.getCookie(url);
    Vector<String> cookie = getCookieNamesByUrl(cookieString);
    if (cookie == null || cookie.isEmpty()) {
        return;
    }
    int len = cookie.size();
    for (int i = 0; i < len; i++) {
        pCookieManager.setCookie(url, cookie.get(i) + "=-1");
    }
    pCookieManager.flush();
}
 
開發者ID:JaeNuguid,項目名稱:Kids-Portal-Android,代碼行數:16,代碼來源:Utils_UserAgent.java

示例8: getCookie

import android.webkit.CookieManager; //導入方法依賴的package包/類
private String getCookie(String url) {
    CookieManager cookieManager = CookieManager.getInstance();
    return cookieManager.getCookie(url);
}
 
開發者ID:TakWolf,項目名稱:CNode-OAuth-Login-Android,代碼行數:5,代碼來源:CNodeOAuthLoginView.java

示例9: getCookie

import android.webkit.CookieManager; //導入方法依賴的package包/類
@Override
public String getCookie(String url) {
    CookieManager cookieManager = CookieManager.getInstance();
    return cookieManager.getCookie(url);
}
 
開發者ID:Justson,項目名稱:AgentWeb,代碼行數:6,代碼來源:DefaultSonicRuntimeImpl.java

示例10: onKeyDown

import android.webkit.CookieManager; //導入方法依賴的package包/類
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

	if (keyCode == KeyEvent.KEYCODE_BACK) {

		stopAudioAndVideo();

		CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(UIWebview.this);
		cookieSyncManager.sync();
		CookieManager cookieManager = CookieManager.getInstance();
		if (cookieManager.getCookie(Constants.urlHost) == null && url != null && url.matches(".+login")) {
			finish();
			System.exit(0);
			return true;
		}
		if (isFull) {
			return super.onKeyDown(keyCode, event);
		}
		String currentUrl = webView.getUrl();
		Log.d("currentUrl", currentUrl);
		if (currentUrl.matches(".+newwin=1.*|.+error.html.+") || currentUrl.matches("^http.+")) {
			Log.d("currentUrl", "false");
			this.setResult(2002);
			this.finish();
			if (animate == 1) {
				overridePendingTransition(R.anim.none, R.anim.push_bottom_out);
			} else if (animate == 2) {
				overridePendingTransition(R.anim.none, R.anim.slide_right_out);
			}
			return true;
		}

		else {
			Log.d("currentUrl", "true");
			this.runOnUiThread(new Runnable() {

				@Override
				public void run() {
					webView.evaluateJavascript("history.go(-1)", null);
				}

			});

			return false;
		}
	} else {

		return super.onKeyDown(keyCode, event);
	}
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:51,代碼來源:UIWebview.java

示例11: getCookie

import android.webkit.CookieManager; //導入方法依賴的package包/類
public static void getCookie(String url) {
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.getCookie(url);
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:5,代碼來源:AppUtils.java


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