本文整理匯總了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();
}
示例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();
}
示例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();
}
}
示例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;
}
}
示例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();
}
示例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();
}
示例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();
}
}
示例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");
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
示例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();
}
}
示例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();
}
示例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);
}