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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:53:00+00:00 2026-05-19T11:53:00+00:00

I am using this code of snippet to download mp4 files from server. Normally

  • 0

I am using this code of snippet to download mp4 files from server. Normally file get download properly,
but sometime my downloading process stops downloading automatically. Progress bar stop incrementing. Is there any kernel process that stop download.

//+++++++++= FUnction Call ++++++++++++++++

DOWNLOAD_FILE_NAME = "demo.mp4";
grabURL("mp4 file server url");  

//+++++++++++++++++++++++++++++++++++++++++

public void grabURL(String url) {  

          new GrabURL().execute(url); 

    }
private class GrabURL extends AsyncTask<String, Void, Void> {  
                  private final HttpClient Client = new DefaultHttpClient();  
                  private String Content;  
                  private String Error = null;  
                  private ProgressDialog Dialog = new ProgressDialog(SlideShow.this);  

                  protected void onPreExecute() {  


                   showDialog(DIALOG_PROGRESS);
               mProgressDialog.setProgress(0);

                  }  

          protected Void doInBackground(String... url) {  
              int count;

              try {
                  URL url2 = new URL(url[0]);
                  URLConnection conexion = url2.openConnection();
                  conexion.setUseCaches(true);
                  conexion.connect();

                  // this will be useful so that you can show a tipical 0-100% progress bar
                  int lenghtOfFile = conexion.getContentLength();
                  mProgressDialog.setMax(lenghtOfFile);
                  // downlod the file
                  InputStream input = new BufferedInputStream(url2.openStream());
                  OutputStream output = new FileOutputStream(DOWNLOAD_FILE_NAME);

                  byte data[] = new byte[1024];

                  while ((count = input.read(data)) != -1) {

                      mProgressDialog.incrementProgressBy(data.length);
                          output.write(data, 0, count);
                  }

                  output.close();
                  input.close();
              } catch (Exception e) {}
              return null;
          }  
  • 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-05-19T11:53:01+00:00Added an answer on May 19, 2026 at 11:53 am

    On mobile device internet connection has to be treated as very unreliable.

    Your code shows a downloading method but no connection management.
    If your internet connection stops for some reason, your code won’t be able to relaunch it.

    You can use the a broadcast receiver from the ConnectivityManager : http://developer.android.com/reference/android/net/ConnectivityManager.html
    to be notified when the connection drops and relaunch your download from there when the connection is up again.

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

Sidebar

Related Questions

I am using this code snippet to add KeyDown event handler to any element
I have the following code snippet: using (SPSite site = new SPSite(this.ListAddress)) { using
This is the snippet of code i'm using now: def countOccurences(a, b) #counts the
Using this code to zip a folder and it works perfect on small files
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1
I'm using this code, and I get the stack trace that is listed below.
by using web services we are able to download file from cloud to buffer
I'm using this little jewel of a Django code snippet to edit a ManyToManyField
I used this code snippet to export data to Excel using Open XML. The
This code snippet gets a Json data from a API hosted in my localhost.

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.