0

I am trying to implement asynchronus http client for Android and I am haveing a trouble with type mismatch:

The method execute(HttpUriRequest) in the type HttpClient is not applicable for the arguments (HttpRequest)    

I am doing all based on this tutorial: http://blog.androgames.net/12/retrieving-data-asynchronously/

Have found a type in AsynchronousSender - private HttpRequest request; but I have still problem with above which occurs in:

public void run() {
    try {
        final HttpResponse response;
        synchronized (httpClient) {
            response = getClient().execute(request); //<-- here is that problem
        }
        // process response
        wrapper.setResponse(response);
        handler.post(wrapper);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Can you suggest anything ?

cheers, /Marcin

1 Answer 1

2

The code snippets on http://blog.androgames.net/12/retrieving-data-asynchronously/ are wrong. To fix it just replace HttpRequest with HttpUriRequest since the method signature is: HttpClient#execute(HttpUriRequest). It shouldn't be any problem since most requests you work with are HttpUriRequest instances.

Sign up to request clarification or add additional context in comments.

2 Comments

Not working that way as protected AsynchronousSender(HttpRequest request... method is expecting request to be HttpRequest type
@Marcin: Yes, but AsynchronousSender snippet is incorrect - you should update it and replace HttpRequest with HttpUriRequest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.