3

我正在尝试通过 shouldOverrideUrlLoading() 方法在 webview 中获取 cookie,但出现此错误。请看我下面的代码,

WebViewClient loginClient = new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            CookieManager cookieManager = CookieManager.getInstance();
            final String cookie = cookieManager.getCookie(url);

            //Some Code after this
        }
 }

我得到这个错误,

java.lang.IllegalStateException: CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()
4

1 回答 1

1

CookieSyncManager.createInstance(this);在您的活动onCreate()方法中使用。该错误清楚地表明createInstance()需要在调用之前调用getInstance()

于 2013-07-31T09:46:45.973 回答