浏览代码

appearantly CookieManager.getInstance() can throw an Exception without saying so...

tobiaskaminsky 7 年之前
父节点
当前提交
2af14be41b
共有 1 个文件被更改,包括 11 次插入6 次删除
  1. 11 6
      src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

+ 11 - 6
src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -69,6 +69,7 @@ import android.text.Editable;
 import android.text.InputType;
 import android.text.TextUtils;
 import android.text.TextWatcher;
+import android.util.AndroidRuntimeException;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
@@ -345,13 +346,17 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     }
 
     private void deleteCookies() {
-        CookieSyncManager.createInstance(this);
-        CookieManager cookieManager = CookieManager.getInstance();
+        try {
+            CookieSyncManager.createInstance(this);
+            CookieManager cookieManager = CookieManager.getInstance();
 
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-            cookieManager.removeAllCookies(null);
-        } else {
-            cookieManager.removeAllCookie();
+            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+                cookieManager.removeAllCookies(null);
+            } else {
+                cookieManager.removeAllCookie();
+            }
+        } catch (AndroidRuntimeException e) {
+            Log_OC.e(TAG, e.getMessage());
         }
     }