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

  • Home
  • SEARCH
  • 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 8203397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:32:29+00:00 2026-06-07T07:32:29+00:00

I have one Thread Safe HttpClient for the whole application, and I have a

  • 0

I have one Thread Safe HttpClient for the whole application, and I have a Service and an Activity that are making a various REST API calls very frequently in separate Threads.
And sometimes it comes to the point where I need to cancel a started HttpRequest, because I already need to start another with an updated data.
I don’t want to make user wait for the first request to finish, and then wait for the second one, and maybe at this point user will update the data again and I’ll need to call the third request.
So what I want to do is cancel request with an old data and start a new one. I tried cancelling the AsyncTask, but for some reason it doesn’t cancel the started request. Here’s my code:

if (getAlbumImage != null && getAlbumImage.getStatus() == AsyncTask.Status.RUNNING) {
    Log.d(VibesApplication.VIBES, "cancelling image loader");
    getAlbumImage.cancel(true);
}
getAlbumImage = new GetAndSetAlbumImage();
getAlbumImage.execute(performer, name);

Also I tried shutting down the connection manager. as suggested here: https://stackoverflow.com/a/7311393/1032286
But I have only one client and manager, I don’t want to create them every time I make a REST call.
What should I do? I would be glad if there’s a way to cancel all running requests, but if there’s a way to cancel separate ones, that would be neat.

  • 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-07T07:32:30+00:00Added an answer on June 7, 2026 at 7:32 am

    Try yourHttpRequest.abort()

    Both HttpGet and HttpPost implement AbortableHttpRequest and it has abort() method

    http://developer.android.com/reference/org/apache/http/client/methods/AbortableHttpRequest.html

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

Sidebar

Related Questions

I have a server that receives various xml messages from clients (one thread per
Is openpyxl thread safe? I'm hoping to have one thread changing the worksheet while
I have one thread that is receiving data over a socket like this: while
Let's say that I have the following code that's run in one thread of
Possible Duplicate: Are C# arrays thread safe? I have a program that is single-threaded
I am writing an update application in Python 2.x. I have one thread (ticket_server)
I have a multi threaded application which has one producer thread and several consumer
I have a Singleton class that uses the thread-safe Singleton pattern from Jon Skeet
I have a list where one thread just does push_back and other thread occasionally
Assume I have one threadpool and each thread is running following method: void runMe(HashMap

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.