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

The Archive Base Latest Questions

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

While uploading multiple image at a time i want to show progress bar which

  • 0

While uploading multiple image at a time i want to show progress bar which show the progress bar in statusbar notification area with the info 1/5 and 2/5 and so on. where 1 is no of image uploaded and 5 is total no of image to be uploaded.

here i am able show progress bar in notification area. can any one suggest me, how to calculate no of image uploaded(finished) to show in progress bar (like 1/5)update. thanks in advance.

For making more clear

i have a asyntask which upload a single image to server. but i am not able to do

1> calculate size of total image (say for example 5 image)

2>how to find no of image uploaded in total 5 image

private class FileUploadTask extends AsyncTask<Object, Integer,String> {

    private ProgressDialog dialog;

    @Override
    protected void onPreExecute() {
        dialog = new ProgressDialog(context);
        dialog.setMessage("Uploading...");
        dialog.setIndeterminate(false);
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setProgress(0);
        dialog.show();
    }

    @Override
    protected String doInBackground(Object... arg0) {
        try {
            File file = new File("/mnt/sdcard/DCIM/100MEDIA/IMAG0149.jpg");
            FileInputStream fileInputStream = new FileInputStream(file);
            byte[] bytes = new byte[(int) file.length()];
            fileInputStream.read(bytes);
            fileInputStream.close();

            URL url = new URL("http://android.com.bd/form.php");
            HttpURLConnection connection = 
                    (HttpURLConnection) url.openConnection();
            OutputStream outputStream = connection.getOutputStream();

            int bufferLength = 1024;
            for (int i = 0; i < bytes.length; i += bufferLength) {
                int progress = (int)((i / (float) bytes.length) * 100);
                Log.i("progress",progress+"dfdf");
                publishProgress(progress);
                if (bytes.length - i >= bufferLength) {
                    outputStream.write(bytes, i, bufferLength);
                } else {
                    outputStream.write(bytes, i, bytes.length - i);
                }
            }
            publishProgress(100);

            outputStream.close();
            outputStream.flush();

            InputStream inputStream = connection.getInputStream();
            // read the response
            inputStream.close();
            return "ok";

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    protected void onProgressUpdate(Integer... progress) {
        dialog.setProgress(progress[0]);
    }

    @Override
    protected void onPostExecute(String result) {
        Log.v("sds", result);
        try {
            dialog.dismiss();
        } catch(Exception e) {
        }

    }

}
  • 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-11T14:59:10+00:00Added an answer on June 11, 2026 at 2:59 pm

    Take a look at this TL;DR blog post/tutorial. You should be able to do something similar. You’ll want to use a ProgressDialog, updating its state using an ASyncTask. If you’re already using an ASyncTask for your image upload, you already have the pieces in place.

    http://toolongdidntread.com/android/android-multipart-post-with-progress-bar/

    Also take a look at this SO question – Download a file with Android, and showing the progress in a ProgressDialog. Your question has been answered before. You’ll just need to adapt the solution to display the progress bar at 1/5, 2/5, etc by customizing onProgressUpdate. I haven’t tested this code, but I’d imagine something along these lines will allow you to display the progress incrementally like you want.

        @Override
        protected void onProgressUpdate(Integer... progress) {
            super.onProgressUpdate(progress);
            if (progress[0] < 20) {            
                mProgressDialog.setProgress(0);
            } else if (progress[0] < 40) {            
                mProgressDialog.setProgress(20);
            }
            else if (progress[0] < 60) {            
                mProgressDialog.setProgress(40);
            }
            else if (progress[0] < 80) {            
                mProgressDialog.setProgress(60);
            }
            else if (progress[0] < 100) {            
                mProgressDialog.setProgress(80);
            }
            else if (progress[0] == 100) {            
                mProgressDialog.setProgress(100);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project i want to show the progress bar while uploading files. I
I want to restrict image size while uploading. Is there any jQuery plugin to
While uploading a file bigger than post_max_size in Symfony, the uploaded file is allocated
I want to add watermark on photos while uploading with paperclip I've got same
While user uploading a file, is it possible to know if the uploaded file
How to a create thumb image while uploading a video, am using the following
Is it possible to reduce image size while uploading ? Can the size be
How to validate corrupt image file while uploading using Rails if the corrupted jpg
Here's the situation. While uploading a video, I want to capture a screenshot of
I am facing the following issue while uploading the video from my android application.

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.