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


Java CookieSyncManager.createInstance方法代碼示例

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


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

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

示例2: syncCookie

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
public static void syncCookie(Context context) {
    PersistentCookieStore cookieStore = new PersistentCookieStore(context);
    List<Cookie> cookies = cookieStore.getCookies();

    CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    for (int i = 0; i < cookies.size(); i++) {
        Cookie eachCookie = cookies.get(i);
        cookieManager.setCookie(Global.HOST, String.format("%s=%s; Domain=%s; Path=%s; Secure; HttpOnly",
                eachCookie.getName(), eachCookie.getValue(), eachCookie.getDomain(),
                eachCookie.getPath()));
    }

    CookieSyncManager.getInstance().sync();

}
 
開發者ID:huang303513,項目名稱:Coding-Android,代碼行數:17,代碼來源:Global.java

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

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

示例5: clearCachedAuthenticationData

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
private void clearCachedAuthenticationData() {
    if (oauthView != null) {
        oauthView.clearCache(true);
        oauthView.clearFormData();
        oauthView.clearHistory();
    }
    // wipe out cookies.
    CookieSyncManager.createInstance(this);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();

    deleteDatabase("webview.db");
    deleteDatabase("webviewCache.db");
    File cacheDirectory = getCacheDir();
    SdkUtils.deleteFolderRecursive(cacheDirectory);
    cacheDirectory.mkdir();
}
 
開發者ID:box,項目名稱:box-android-sdk,代碼行數:18,代碼來源:OAuthActivity.java

示例6: 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:dannegm,項目名稱:BrillaMXAndroid,代碼行數:24,代碼來源:Utility.java

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

示例8: logout

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
public void logout(Context context) {
    f.c(f.d, "logout() --start");
    CookieSyncManager.createInstance(context);
    setAccessToken(null, null);
    setOpenId(context, null);
    f.c(f.d, "logout() --end");
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:8,代碼來源:QQAuth.java

示例9: clearCookies

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
public static void clearCookies(Context context) {
    // Edge case: an illegal state exception is thrown if an instance of
    // CookieSyncManager has not be created. CookieSyncManager is normally
    // created by a WebKit view, but this might happen if you start the
    // app, restore saved state, and click logout before running a UI
    // dialog in a WebView -- in which case the app crashes
    @SuppressWarnings("unused")
    CookieSyncManager cookieSyncMngr = CookieSyncManager
            .createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:13,代碼來源:FoursquareUtils.java

示例10: onCreate

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override
/**
 * When the dialog is created, we add the webview and load the authorize url.
 */
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	
	mProgress = new ProgressDialog(getContext());
	mProgress.requestWindowFeature(Window.FEATURE_NO_TITLE);
	mProgress.setMessage("Loading...");
	
	mLayout = new LinearLayout(getContext());
	mLayout.setOrientation(LinearLayout.VERTICAL);

	mWebView = new WebView(getContext());
	mWebView.setVerticalScrollBarEnabled(false);
	mWebView.setHorizontalScrollBarEnabled(false);
	//mWebView.getSettings().setSupportZoom(false);
	mWebView.setLayoutParams(MATCH);
	mWebView.getSettings().setJavaScriptEnabled(true);

	mWebView.setWebViewClient(new OAuthWebViewClient());
       mWebView.setWebChromeClient(new WebChromeClient());
       
       mWebView.loadUrl(mReq.getLocationUri());
       mLayout.addView(mWebView);
       
       Display display = getWindow().getWindowManager().getDefaultDisplay();
	addContentView(mLayout, new FrameLayout.LayoutParams(display.getWidth() - 20, display.getHeight() - 20));
	CookieSyncManager.createInstance(getContext());
	CookieManager cookieManager = CookieManager.getInstance();
	cookieManager.removeAllCookie();
	
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:39,代碼來源:OAuthDialog.java

示例11: handleThrowException

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
private void handleThrowException(Directive directive) {
    Payload payload = directive.getPayload();
    if (payload instanceof ThrowExceptionPayload) {
        ThrowExceptionPayload throwExceptionPayload = (ThrowExceptionPayload) payload;
        if (throwExceptionPayload.getCode() == ThrowExceptionPayload.Code.UNAUTHORIZED_REQUEST_EXCEPTION) {
            //  分別清空token 和 cookie
            OauthPreferenceUtil.clearAllOauth(DcsSampleApplication.getInstance());
            HttpConfig.setAccessToken("");
            CookieSyncManager.createInstance(DcsSampleApplication.getInstance());
            CookieManager.getInstance().removeAllCookie();
        }
        fireThrowException(throwExceptionPayload);
    }
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:15,代碼來源:SystemDeviceModule.java

示例12: onCreate

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    WebView webview = (WebView) findViewById(R.id.vkontakteview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.clearCache(true);

    //Чтобы получать уведомления об окончании загрузки страницы
    webview.setWebViewClient(new VkontakteWebViewClient());

    //otherwise CookieManager will fall with java.lang.IllegalStateException: CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()
    CookieSyncManager.createInstance(this);

    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();

    String clientId = getIntent().getStringExtra(EXTRA_CLIENT_ID);
    String scope = getIntent().getStringExtra(EXTRA_SCOPE);
    String groupIds = getIntent().getStringExtra(EXTRA_GROUP_IDS);

    String url = Auth.getUrl(clientId, scope, groupIds);
    webview.loadUrl(url);
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:27,代碼來源:LoginActivity.java

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

示例14: a

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
private void a(Context context, String str, Bundle bundle, String str2, IUiListener iUiListener) {
    f.a(f.d, "OpenUi, showDialog --start");
    CookieSyncManager.createInstance(context);
    bundle.putString("oauth_consumer_key", this.mToken.getAppId());
    if (this.mToken.isSessionValid()) {
        bundle.putString("access_token", this.mToken.getAccessToken());
    }
    String openId = this.mToken.getOpenId();
    if (openId != null) {
        bundle.putString("openid", openId);
    }
    try {
        bundle.putString(Constants.PARAM_PLATFORM_ID, Global.getContext().getSharedPreferences(Constants.PREFERENCE_PF, 0).getString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF));
    } catch (Exception e) {
        e.printStackTrace();
        bundle.putString(Constants.PARAM_PLATFORM_ID, Constants.DEFAULT_PF);
    }
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(str2);
    stringBuilder.append(Util.encodeUrl(bundle));
    String stringBuilder2 = stringBuilder.toString();
    f.b(f.d, "OpenUi, showDialog TDialog");
    if (SocialConstants.ACTION_CHALLENGE.equals(str) || SocialConstants.ACTION_BRAG.equals(str)) {
        f.b(f.d, "OpenUi, showDialog PKDialog");
        new PKDialog(this.b, str, stringBuilder2, iUiListener, this.mToken).show();
        return;
    }
    new TDialog(this.b, str, stringBuilder2, iUiListener, this.mToken).show();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:30,代碼來源:SocialApiIml.java

示例15: l

import android.webkit.CookieSyncManager; //導入方法依賴的package包/類
private l(Context context) {
    this.a = context;
    try {
        this.c.allowCoreThreadTimeOut(true);
    } catch (Exception e) {
    }
    CookieSyncManager.createInstance(this.a);
    CookieManager.getInstance().setAcceptCookie(true);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:10,代碼來源:l.java


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