Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:27:14+00:00 2026-06-02T18:27:14+00:00

So right now, I am trying to implement an asynchronous call which calls my

  • 0

So right now, I am trying to implement an asynchronous call which calls my BasicHttpClient to get Http response from the internet, when the Http client done its work, it calls one of Callee class’s methods.

Generally, my implementation looks like this.

public class BasicHttpClientAsync {
    private OnRequestFinishedListener mListener;

    public interface OnRequestFinishedListener {
        public void onRequestFinished(HttpResponse httpResponse);

        public void onRequestFinished(ClientProtocolException e);

        public void onRequestFinished(IOException e);
    }

    public BasicHttpClient(OnRequestFinishedListener listener) {
        this.mListener = listener;
    }

    private Runnable task = new Runnable() {
        @override
        public void run() {
            HttpClient httpClient = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(URL);
            HttpResponse httpResponse = httpClient.execute(httpGet);

            mListener.onRequestFinished(httpResponse);
        }
    };

    public void getResponse() {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        FuturkTask<?> futureTask = new FutureTask<Object>(task, null);
        executor.execute(futureTask);
    }
}

public class Callee implements OnRequestFinishedListener {
    public void getResult() {
        BasicHttpClientAsync httpClient = new BasicHttpClientAsync(this);
        httpClient.getResponse();
    }

    @override
    public void onRequestFinished(HttpResponse httpResponse) {
        System.out.println(httpResponse.toString());
    }
}

The code has been largely simplified, and main() method calls Callee class’s getResult() method. btw all of the exceptions has been handled, and send back to callee using callback.

However, the “onRequestFinished” in the Callee class seems like never get called.

Help please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:27:15+00:00Added an answer on June 2, 2026 at 6:27 pm

    Turns out it’s because I didn’t add all of jars of apache’s HttpComponents into my Java Build Path, which causing HttpClient mHttpClient = new DefaultHttpClient() throws out an exception. However, I am using Runnable, so there is no way for me to catch that exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm trying to implement this interface with an int which represents a
I'm trying to implement paging in a custom ListAdapter. Right now I'm just making
Right now I'm trying desperately to get @font-face to work in my website. This
Right now i am trying to implement something like the RowDetails feature of the
I'm trying to implement validation in my ASP.NET Webforms application. Right now, the only
I'm working on a project right now where I'm trying to implement the NEAT
For a fun project I'm trying to implement the BitTorrent spec, and right now
I am trying to implement a multiple file upload where I am right now
I'm writing a program trying to implement a toy XML processor. Right now the
I'm having a bit of trouble right now trying to implement word wrapping for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.