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 8546335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:59:39+00:00 2026-06-11T12:59:39+00:00

My application is having a requirement like pause or resume a we call(downloading a

  • 0

My application is having a requirement like pause or resume a we call(downloading a file). In my application I need to call a set of Urls sequentially or parallelly and I have to get the time taken to finish the call. It has an option to pause and resume while calling a url. How can I achieve it. I tried Async Task but it does not have pause and resume option. If anybody have an idea please help me for the same.

  • 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-11T12:59:40+00:00Added an answer on June 11, 2026 at 12:59 pm

    You cannot pause/resume one web service call: HTTP protocol simply does not support it. You can try playing with HTTP/1.1 keep-alive connection, but that may be rather painful and I would strongly advise against it. Instead, what you should do is pause between URL calls. That is, make one call, retrieve data, then either go to the next one or pause before going to the next one.

    You can simply achieve this with AsyncTask. In your class declare a boolean variable to keep run state (pause/run) and an indicator member variable of type Object – you’ll need it for notifications.

    Then in your doInBackground method loop over your URL’s calling each one sequentially. When you completed one call, check that variable. If it’s set to false (i.e. pause has been called), then wait until it’s set to true – with something like this:

    for(each url in your list) {
        //make the call and retrieve the data
        ....
        if(!this.runState) { //pause has been called
            // the below code blocks until notified
            synchronized(indicator) {
                try {
                    runState.wait();
                } catch (InterruptedException e) {
                    // Nothing needs to be done here
                }
            }
        }
    }
    

    Finally, you will need stop/resume methods:

    public synchronized void pause() {
        runState = false;
    }
    
    public synchronized void resume() {
        runState = true;
        //this code notifies the process (in the loop) to stop waiting
        synchronized(syncObject) {
            indicator.notify();
        }
    }
    

    UPDATE

    If you want to stop and resume a file download using HTTP, then there are two things you need to do.

    1. Handle InputStream from the connection manually, reading, say, 1024 bytes at a time. Keep track of how much you’re read in total. After each read check that the “pause” hasn’t been called. If it has, then wait until the “resume” has been called.

    2. When resume has been called, attempt to continue reading the stream. If the stream has been closed by the server end, then re-establish connection and specify the offset using Range HTTP header, e.g. Range: bytes=4096- will request that the server resumes transfer from byte 4096 onward of the stream. Note that not all servers support this header. If your particular server does not, then you’re out of luck.

    The actual pause/resume/check logic would be the same as described above.

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

Sidebar

Related Questions

A small - little question. I have seen many application having buttons like following.
We have a big application having 13 modules. Depending on the customer requirement, we
I have a web application with a simple file upload requirement (max 1 mb).
i have made an application having entity framewrok. It is wpf application, now it
I have created an tab bar application having 3 tab. When I am launching
I've found myself having a requirement to configure log4net based on a file relative
I have a requirement to play YouTube video content from within an Android application
We have a requirement from a client to protect the database our application uses,
I have a requirement to perform HTTP authentication logic within a servlet application, rather
I have a requirement to build 'versioning' into an application and was wondering how

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.