本文整理汇总了Java中android.webkit.CookieManager.removeAllCookie方法的典型用法代码示例。如果您正苦于以下问题:Java CookieManager.removeAllCookie方法的具体用法?Java CookieManager.removeAllCookie怎么用?Java CookieManager.removeAllCookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.CookieManager
的用法示例。
在下文中一共展示了CookieManager.removeAllCookie方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearCookies
import android.webkit.CookieManager; //导入方法依赖的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();
}
}
示例2: onCreate
import android.webkit.CookieManager; //导入方法依赖的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();
}
示例3: logout
import android.webkit.CookieManager; //导入方法依赖的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;
}
示例4: clearCookies
import android.webkit.CookieManager; //导入方法依赖的package包/类
/**
* @see <a href="http://stackoverflow.com/questions/28998241/how-to-clear-cookies-and-cache-of-webview-on-android-when-not-in-webview" />
* @param context
*/
@SuppressWarnings("deprecation")
public static void clearCookies(Context context)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().flush();
} else
{
CookieSyncManager cookieSyncMngr= CookieSyncManager.createInstance(context);
cookieSyncMngr.startSync();
CookieManager cookieManager= CookieManager.getInstance();
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();
cookieSyncMngr.stopSync();
cookieSyncMngr.sync();
}
}
示例5: collectCookies
import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private String[] collectCookies() {
String cookies = CookieManager.getInstance().getCookie(Endpoints.BASE_URL);
if (cookies == null || cookies.isEmpty()) {
return null;
}
//See: http://stackoverflow.com/questions/28998241/how-to-clear-cookies-and-cache-of-webview-on-android-when-not-in-webview
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().flush();
} else {
CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(getActivity().getApplicationContext());
cookieSyncMngr.startSync();
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();
cookieSyncMngr.stopSync();
cookieSyncMngr.sync();
}
return cookies.split(" ");
}
示例6: clearCookie
import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void clearCookie() {
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeSessionCookie();
cookieManager.removeAllCookie();
cookieSyncManager.sync();
}
示例7: clearCookies
import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void clearCookies(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().flush();
} else {
CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
cookieSyncMngr.startSync();
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();
cookieSyncMngr.stopSync();
cookieSyncMngr.sync();
}
}
示例8: onCreate
import android.webkit.CookieManager; //导入方法依赖的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);
}
示例9: clearCookies
import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public void clearCookies() {
// TODO Break out web storage deletion into its own option/action
// TODO clear web storage for all sites that are visited in Incognito mode
WebStorage storage = WebStorage.getInstance();
storage.deleteAllData();
CookieManager c = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
c.removeAllCookies(null);
} else {
CookieSyncManager.createInstance(this);
c.removeAllCookie();
}
}
示例10: clearCookies
import android.webkit.CookieManager; //导入方法依赖的package包/类
public static void clearCookies(@NonNull Context context) {
CookieManager c = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
c.removeAllCookies(null);
} else {
//noinspection deprecation
CookieSyncManager.createInstance(context);
//noinspection deprecation
c.removeAllCookie();
}
}
示例11: clearCookie
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void clearCookie() {
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
CookieSyncManager.getInstance().sync();
}
示例12: deleteCookie
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void deleteCookie() {
CookieSyncManager.createInstance(this.context).sync();
CookieManager instance = CookieManager.getInstance();
instance.setAcceptCookie(true);
instance.removeAllCookie();
LemallPlatform.getInstance().setCookieLinkdata("");
System.gc();
}
示例13: clearCookies
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void clearCookies() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().flush();
} else {
CookieSyncManager cookieSyncManager =
CookieSyncManager.createInstance(ExpressApplication.getApplication());
cookieSyncManager.startSync();
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
cookieManager.removeSessionCookie();
cookieSyncManager.startSync();
cookieSyncManager.sync();
}
}
示例14: onCreate
import android.webkit.CookieManager; //导入方法依赖的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();
}
示例15: clearCookies
import android.webkit.CookieManager; //导入方法依赖的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();
}