Code example for DefaultHttpClient

Methods: getCookieStore, getParams

0
    private SharedPreferences mSettings;
 
    public WebsiteInteraction(Context context) {
        mContext    = context;
        mSettings   = PreferenceManager.getDefaultSharedPreferences(mContext);
        mHttpClient = new DefaultHttpClient();
        mHttpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
                "Apache-HttpClient/potdroid " + mSettings.getString("unique_uagent", "potdroid"));
 
        // check if login cookie exists. If so, attach it to the 
        // http client 
        if (mSettings.contains("cookie_name")) {
            BasicClientCookie cookie = new BasicClientCookie(mSettings.getString("cookie_name",
                    null), mSettings.getString("cookie_value", null));
            cookie.setPath(mSettings.getString("cookie_path", null));
            cookie.setDomain(mSettings.getString("cookie_url", null));
            mHttpClient.getCookieStore().addCookie(cookie);
        } 
    } 
 
    /** 
     * Get a xml document from the mods.de api