Code example for UrlEncodedFormEntity

0
    } 
     
    private Authentication.AuthenticationData doAuthentication(final String url, final ArrayList<NameValuePair> data)
    	throws AuthenticationException, IOException { 
        final HttpPost post = new HttpPost(url);
        post.setEntity(new UrlEncodedFormEntity(data));
        HttpEntity entity = null;
 
        final HttpResponse response = HttpManager.execute(post);
        Authentication.AuthenticationData authResponse;
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            entity = response.getEntity();
            authResponse = parseResponse(entity.getContent());
            if (!authResponse.looksValid()) {
                Log.i(TAG, "Failed to authenticate user");
                throw new AuthenticationException("Failed to authenticate user");
            } 
        } else { 
            Log.w(TAG, "Request failed, http status code was not OK.");
            throw new IOException();
        }