I need to use the CookieManager class for devices with version 9 or higher. My code looks like this:
public class HttpUtils { private static CookieManager cookie_manager = null; @TargetApi(9) public static CookieManager getCookieManager() { if (cookie_manager == null) { cookie_manager = new CookieManager(); CookieHandler.setDefault(cookie_manager); } return cookie_manager; } }
When I run this on emulator 2.2; I have this error log;
Could not find class 'java.net.CookieManager', referenced from method com.application.utils.HttpUtils.getCookieManager
When I need a CookieManager, I call this method with the os version check;
if (Build.VERSION.SDK_INT >= 9) ...
So, in my application, if version 2.2 or lower; this method is never called. My question is: why am I seeing this error log?
syloc source share