当前位置: 首页>>代码示例>>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;未经允许,请勿转载。