Background:
I'm acquireing cookies through my app and use them internally by making requests to http. Users can switch to webview any given time, in which case I sync/inject cookies to webView.
Code for synchronizing cookies to webview using CookieSyncManager:
CookieSyncManager.createInstance(a);
CookieManager cm = CookieManager.getInstance();
cm.setCookie(domain, cookieName + "=" + cookieValue);
CookieSyncManager.getInstance().sync();
This works on all API levels except API 15+ (Android 4.0, Ice Cream Sandwich). The CookieManager API is not deprecated.
What is causing this problem and are there any workarounds?
WebViewClient.shouldOverrideUrlLoading
to use theApache DedfaultHttpClient
to acquire webpage using cookies and inject the HTML into webview withwebView.loadData
(meaning, you handle all the logic and webview is used only for displaying/rendering HTML) – Embassy