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