Code example for CookieManager

0
    // This executes in non-UI thread. No UI calls from here (including Toast) 
    @Override 
    protected ArrayList<HashMap<String, String>> doInBackground(String... urls) {
        HttpURLConnection conn = null;
        try { 
            CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
            URL url = new URL(urls[0]);
            conn = (HttpURLConnection) url.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            return new RssReader().read(in);
        } catch (Exception e) {
            Log.w(TAG, e.toString());
            return null; 
        } 
        finally { 
            if (conn != null) {
                conn.disconnect();
            } 
        } 
    }