I am trying to get cookies in webview on shouldOverrideUrlLoading() method and i got this error. Please have a look at my code below,
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
}
}
And i m getting this error,
java.lang.IllegalStateException: CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()
Use CookieSyncManager.createInstance(this); in your Activity's onCreate() Method. The error clearly says createInstance() need to be called before calling getInstance().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With