KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to make a URLConnection that supports cookies. According to the documentation I can use: CookieManager cookieManager = new CookieManager(); CookieHandler.setDefault(cookieManager); I couldn't get this code to work, then I saw this only works for API 9 (2.3). However, I don't get an error using CookieManager in an older emulator, CookieManager exists, but can't be constructed. Is there any way to make this work for earlier versions? I tried: cookieManager.setAcceptCookie(true); URLConnection con = u.openConnection(); con.setRequestProperty("Cookie", cookieManager.getInstance().getCookie(url);); con.setDoOutput(true); con.connect(); String addCookie = con.getHeaderField("Set-Cookie"); System.out.println(con.getHeaderFields().toString()); if (addCookie!=null) { cookieManager.getInstance().setCookie(url, addCookie); } but this doesn't work.
Tags (comma-separated)
Save Edits
Cancel