Android 的WebView使用CookieManager崩溃的问题
2014-07-03 20:18
776 查看
应用里,如果用户退出登陆了,而WebView里还没有退出登陆,这就有点蛋疼了。所以在用户退出时,要清除WebView的Cookie。但是据说调用CookieManager应用可能会崩溃。
先来看下微信是怎么做的,反编绎了下微信的apk,发现是这样的:
在网上找了一些资料:
http://blog.csdn.net/shichaosong/article/details/7949580 里面的FackBook的代码的注释提到 CookieSyncManager如果没有创建,就有可能会导致app crash。
另外这里也提到:
http://www.effecthub.com/topic/66
Android: CookieManager removeAllCookie() Crash
When we use CookieManager.getInstance().removeAllCookie(); to remove cookie ,it's may crash with log fatal signal 11.
just add CookieSyncManager.createInstance(getActivity());we can avoid this crash.
先来看下微信是怎么做的,反编绎了下微信的apk,发现是这样的:
private void a(Activity paramActivity, String[] paramArrayOfString) { Bundle localBundle = new Bundle(); if (paramArrayOfString.length > 0) { localBundle.putString("scope", TextUtils.join(",", paramArrayOfString)); } CookieSyncManager.createInstance(paramActivity); a(paramActivity, "oauth", localBundle, new f(this)); } public final String cl(Context paramContext) { CookieSyncManager.createInstance(paramContext); CookieManager.getInstance().removeAllCookie(); AX(null);
在网上找了一些资料:
http://blog.csdn.net/shichaosong/article/details/7949580 里面的FackBook的代码的注释提到 CookieSyncManager如果没有创建,就有可能会导致app crash。
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(); }
另外这里也提到:
http://www.effecthub.com/topic/66
Android: CookieManager removeAllCookie() Crash
When we use CookieManager.getInstance().removeAllCookie(); to remove cookie ,it's may crash with log fatal signal 11.
just add CookieSyncManager.createInstance(getActivity());we can avoid this crash.
相关文章推荐
- Android 3.X中WebView使用ZOOM崩溃的问题
- 在android4.x中使用自定义的webview中出现ZOOM崩溃的问题
- Android 3.X中WebView使用ZOOM崩溃的问题
- Android 3.X中WebView使用ZOOM崩溃的问题
- Android使用WebView中的js跳转问题
- android--WebView使用addJavascriptInterface在sdk 17的问题解决
- android 使用webview加载网页问题
- android 使用webview访问优酷无法播放视频的问题
- 【Android】webView 使用 系统自带搜索对话框问题
- android,使用webView加载页面,界面空隙问题
- Android WebView使用及苏宁易付宝支付相关问题
- 关于android webview 图片使用同一个src导致只加载第一张的问题
- 【WebView】Android WebView专栏——基本使用及常见问题
- Android WebView 使用过程中遇到的问题与总结
- 关于android的webview 使用的问题 JS无法正常使用 界面切换出现白屏
- android使用webview时按后退退出的问题
- Android使用WebView无法定位问题的解决方法
- android webView 加载HTML代码使用loadData方法中文乱码问题
- Android webview app 直接使用注入 javascript 解决中文输入问题
- Android使用WebView嵌入网页,网页内点击跳转到另一个网页后,返回问题解决