I have an application that makes several web calls in order to get authenticated after which a JSON is returned. My web calls are to an https server and I am using HTTPURlConnection.
I need to store the session in a cookie, after researching around, I found this
http://developer.android.com/reference/java/net/HttpURLConnection.html
Under the sessions with cookies header, it tells you to use this code here
CookieManager cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
However when I try using this code, the new CookieManager(); part highlights in red and says
The constructor CookieManager is not visible
and the Cookiehandler.setDefault also highlights in red and says
The method setDefault(CookieHandler) in the type CookieHandler is not applicable for the arguments (CookieManager)
Does anyone know why this is?
Thanks in advance!
A CookieManager class's instances provide a concrete implementation of CookieHandler. It separates the storage of cookies from the policy surrounding accepting and ignoring cookies.
Open your browser. Android browser: Go to Menu > More > Settings or Menu > Settings > Privacy & Security. Chrome: Go to Menu > Settings > Privacy. Android browser: Tap Clear cache, Clear history, and Clear all cookie data as appropriate.
You're probably trying to use the wrong CookieManager
class. In Android there are 2 classes...
android.webkit.CookieManager
java.net.CookieManager
For this context, you need to use the java.net.CookieManager
class.
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