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


Java CookieSyncManager類代碼示例

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


CookieSyncManager類屬於android.webkit包,在下文中一共展示了CookieSyncManager類的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: onPageFinished

import android.webkit.CookieSyncManager; //導入依賴的package包/類
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);

    // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        CookieManager.getInstance().flush();
    } else {
        CookieSyncManager.getInstance().sync();
    }

    // https://issues.apache.org/jira/browse/CB-11248
    view.clearFocus();
    view.requestFocus();

    try {
        JSONObject obj = new JSONObject();
        obj.put("type", LOAD_STOP_EVENT);
        obj.put("url", url);

        sendUpdate(obj, true);
    } catch (JSONException ex) {
        LOG.d(LOG_TAG, "Should never happen");
    }
}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:25,代碼來源:InAppBrowser.java

示例3: reset

import android.webkit.CookieSyncManager; //導入依賴的package包/類
public void reset() {
	Editor editor = mSharedPref.edit();
	
	editor.putString(ACCESS_TOKEN, 	"");
	editor.putString(USERID, 		"");
	editor.putString(USERNAME, 		"");
	editor.putString(FULLNAME, 		"");
	editor.putString(PROFILPIC, 	"");
	editor.putInt(FOLLOW,0);
	editor.putInt(FOLLOWED,0);
	
	editor.commit();
	
	CookieSyncManager.createInstance(mContext);
	
	CookieManager cookieManager = CookieManager.getInstance();
	cookieManager.removeAllCookie();
}
 
開發者ID:inceleb,項目名稱:InstagramManager-Android,代碼行數:19,代碼來源:InstagramSession.java

示例4: 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

示例5: setCookie

import android.webkit.CookieSyncManager; //導入依賴的package包/類
private void setCookie(Context context, String domain, String sessionCookie) {
    CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    if (sessionCookie != null) {
        // delete old cookies
        cookieManager.removeSessionCookie();
    }
    try {
        Thread.sleep(200);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    cookieManager.setCookie(domain, sessionCookie);

    CookieSyncManager.createInstance(context);
    CookieSyncManager.getInstance().sync();
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:19,代碼來源:BaseWebView.java

示例6: 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

示例7: getExistingCookie

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

示例8: onCreate

import android.webkit.CookieSyncManager; //導入依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mSpinner = new ProgressDialog(getContext());
  mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
  mSpinner.setMessage("Loading...");
  mContent = new LinearLayout(getContext());
  mContent.setOrientation(LinearLayout.VERTICAL);
  setUpTitle();
  setUpWebView();
  Display display = getWindow().getWindowManager().getDefaultDisplay();
  final float scale = getContext().getResources().getDisplayMetrics().density;
  float[] dimensions =
      (display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;
  addContentView(mContent, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f),
      (int) (dimensions[1] * scale + 0.5f)));
  CookieSyncManager.createInstance(getContext());
  CookieManager cookieManager = CookieManager.getInstance();
  cookieManager.removeAllCookie();
}
 
開發者ID:mukeshsolanki,項目名稱:social-login-helper,代碼行數:20,代碼來源:InstagramDialog.java

示例9: toSyncCookies

import android.webkit.CookieSyncManager; //導入依賴的package包/類
private static void toSyncCookies() {

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            CookieSyncManager.getInstance().sync();
            return;
        }

        AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
            @Override
            public void run() {
                if (SysUtils.hasLollipop())
                    CookieManager.getInstance().flush();

            }
        });
    }
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:17,代碼來源:CookiesHandler.java

示例10: sendResponseMessage

import android.webkit.CookieSyncManager; //導入依賴的package包/類
protected void sendResponseMessage(HttpResponse response) {
    super.sendResponseMessage(response);
    Header[] headers = response.getHeaders("Set-Cookie");
    if (headers != null && headers.length > 0) {
        CookieSyncManager.createInstance(this.val$context).sync();
        CookieManager instance = CookieManager.getInstance();
        instance.setAcceptCookie(true);
        instance.removeSessionCookie();
        String mm = "";
        for (Header header : headers) {
            String[] split = header.toString().split("Set-Cookie:");
            EALogger.i("正式登錄", "split[1]===>" + split[1]);
            instance.setCookie(Constants.THIRDLOGIN, split[1]);
            int index = split[1].indexOf(";");
            if (TextUtils.isEmpty(mm)) {
                mm = split[1].substring(index + 1);
                EALogger.i("正式登錄", "mm===>" + mm);
            }
        }
        EALogger.i("正式登錄", "split[1222]===>COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm);
        instance.setCookie(Constants.THIRDLOGIN, "COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm);
        instance.setCookie(Constants.THIRDLOGIN, "COOKIE_APP_ID=" + LemallPlatform.getInstance().getmAppInfo().getId() + ";" + mm);
        CookieSyncManager.getInstance().sync();
        this.val$iLetvBrideg.reLoadWebUrl();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:27,代碼來源:HttpTask.java

示例11: a

import android.webkit.CookieSyncManager; //導入依賴的package包/類
public static void a(Context context, String str, String str2, String str3, String str4) {
    if (!TextUtils.isEmpty(str)) {
        CookieSyncManager.createInstance(context);
        CookieManager instance = CookieManager.getInstance();
        instance.setAcceptCookie(true);
        String str5 = null;
        if (Uri.parse(str).getHost().toLowerCase().endsWith(".qq.com")) {
            str5 = ".qq.com";
        }
        instance.setCookie(str, b("logintype", "MOBILEQ", str5));
        instance.setCookie(str, b("qopenid", str2, str5));
        instance.setCookie(str, b("qaccesstoken", str3, str5));
        instance.setCookie(str, b("openappid", str4, str5));
        CookieSyncManager.getInstance().sync();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:17,代碼來源:a.java

示例12: saveCookie

import android.webkit.CookieSyncManager; //導入依賴的package包/類
private static void saveCookie(String url){
	String cookie = CookieManager.getInstance().getCookie(url);
	if(cookie !=null && !cookie.equals("")){  
           String[] cookies = cookie.split(";");  
           for(int i=0; i< cookies.length; i++){  
               String[] nvp = cookies[i].split("=");  
               BasicClientCookie c = new BasicClientCookie(nvp[0], nvp[1]);  
               //c.setVersion(0);  
               c.setDomain("kyfw.12306.cn");
               MyCookieStore myCookieStore = null;
               if (MyApp.getInstance().getCommonBInfo().getHttpHelper().getHttpClient().getCookieStore()
               		instanceof MyCookieStore){
               	myCookieStore = (MyCookieStore)MyApp.getInstance().getCommonBInfo().getHttpHelper().getHttpClient().getCookieStore();
               }
               if (myCookieStore != null){
               	myCookieStore.addCookie(c);
               }
           }
      }  
	CookieSyncManager.getInstance().sync();
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:22,代碼來源:WebViewUtil.java

示例13: onCreate

import android.webkit.CookieSyncManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //清除cookie
    CookieSyncManager.createInstance(WebViewActivity.this);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();

    setContentView(R.layout.activity_webview);

    mWebView = (WebView) findViewById(R.id.login_webview);

    mIntent = getIntent();
    mUrl = mIntent.getStringExtra("extr_url");

    mProgress = (ProgressBar) findViewById(R.id.login_webview_progress);

    init();
}
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:20,代碼來源:WebViewActivity.java

示例14: 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

示例15: run

import android.webkit.CookieSyncManager; //導入依賴的package包/類
public void run() {
    try {
        Message message = new Message();
        message.what = 2;
        if ("none".equals(DeviceHelper.getInstance(this.a.activity).getDetailNetworkTypeForStatic())) {
            message.arg1 = 1;
            UIHandler.sendMessage(message, this.a);
            return;
        }
        if (ShareSDK.isRemoveCookieOnAuthorize()) {
            CookieSyncManager.createInstance(this.a.activity);
            CookieManager.getInstance().removeAllCookie();
        }
        message.obj = this.a.a.getAuthorizeUrl();
        UIHandler.sendMessage(message, this.a);
    } catch (Throwable th) {
        Ln.e(th);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:j.java


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