Android LlinkedIn无法在WebView中注销
我正在WebView中加载一个URL,在该URL中有LinkedIn登录,登录后无法注销。我已经通过以下两种方式清除了cookies,但问题仍未解决。请帮忙 方式1:Android LlinkedIn无法在WebView中注销,android,webview,linkedin,Android,Webview,Linkedin,我正在WebView中加载一个URL,在该URL中有LinkedIn登录,登录后无法注销。我已经通过以下两种方式清除了cookies,但问题仍未解决。请帮忙 方式1: LISessionManager.getInstance(getApplicationContext()).clearSession(); 方式2: android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "bcookie="); and
LISessionManager.getInstance(getApplicationContext()).clearSession();
方式2:
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "bcookie=");
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "bscookie=");
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "visit=");
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "sl=");
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "lang=1");
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "JSESSIONID=");
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "li_at=");
android.webkit.CookieManager.getInstance().setCookie(".linkedin.com", "bcookie=");
每当我需要在Webview中显示一个简单的HTML页面以外的任何事情时,我都会发疯。他们已经改变/破坏了每个Android版本的一些东西,所以你必须复制每一行代码 有一次,我必须清除我应用程序中某个网络视图的cookies,我使用
cookieManager.removeAllCookie()
,这是继棒棒糖之后被弃用的
我还使用了webview.clearCache()
。根据文档:清除资源缓存。请注意,缓存是针对每个应用程序的,因此这将清除所有使用的WebView的缓存。因此,您不需要实际参考当前的webview(如果此注销在应用程序的单独位置处理,则非常有用)
因此,我通过以下方式结合了这两种解决方案:
CookieManager cookieManager = CookieManager.getInstance();
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean value) {
//Removed?
}
});
cookieManager.flush();
} else {
CookieSyncManager.createInstance(this);
cookieManager.removeAllCookie();
}
new WebView(getApplicationContext()).clearCache(true);
CookieManager CookieManager=CookieManager.getInstance();
if(android.os.Build.VERSION.SDK\u INT>=Build.VERSION\u code.LOLLIPOP){
removeAllCookies(新值回调(){
@凌驾
公共无效onReceiveValue(布尔值){
//移除?
}
});
cookieManager.flush();
}否则{
CookieSyncManager.createInstance(此);
cookieManager.removeAllCookie();
}
新建WebView(getApplicationContext()).clearCache(true);
这解决了我从不同于LinkedIn的网站注销的问题。我不知道您是否需要为您的特定案例完成任何其他特殊技巧。如果您说“删除所有cookies”,则所有链接到的cookies以及给定url cookies都将被删除。但是这里给定的url cookie需要存在。所以我只想清除cookies中的链接。。。我想你现在遇到了我的问题……如果你需要保存一些饼干,那么我的解决方案对你不起作用。对不起,我回复你的时候不知道这个限制。