use of android.webkit.CookieManager in project facebook-api-android-maven by avianey.
the class Utility method clearCookiesForDomain.
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();
}
use of android.webkit.CookieManager in project AgentWeb by Justson.
the class AgentWebConfig method removeAllCookies.
public static void removeAllCookies(Context context) {
if (CookieSyncManager.getInstance() == null)
CookieSyncManager.createInstance(context);
CookieManager cm = CookieManager.getInstance();
cm.removeAllCookie();
}
use of android.webkit.CookieManager in project AgentWeb by Justson.
the class AgentWebConfig method syncCookieToWebView.
/**
*
* okhttp
*
*
*/
public static void syncCookieToWebView(String url, String cookies) {
CookieManager mCookieManager = CookieManager.getInstance();
mCookieManager.setCookie(url, cookies);
}
use of android.webkit.CookieManager in project android-app-common-tasks by multidots.
the class SocialAuthAdapter method signOut.
/**
* Signs out the user out of current provider
*
* @return Status of signing out
*/
@SuppressWarnings("UnusedReturnValue")
public boolean signOut(Context ctx, String providerName) {
// remove cookies
Context appContext = ctx.getApplicationContext();
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
if (providerName != null) {
if (socialAuthManager.getConnectedProvidersIds().contains(providerName))
socialAuthManager.disconnectProvider(providerName);
Editor edit = PreferenceManager.getDefaultSharedPreferences(appContext).edit();
edit.remove(providerName + " key");
edit.apply();
Log.d("SocialAuthAdapter", "Disconnecting Provider");
return true;
} else {
Log.d("SocialAuthAdapter", "The provider name should be same");
return false;
}
}
use of android.webkit.CookieManager in project generic-oauth2-login-for-android by wareninja.
the class Utils method clearCookies.
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();
}
Aggregations