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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:15:23+00:00 2026-06-05T09:15:23+00:00

I want to put progress bar when object is sent to the server. But

  • 0

I want to put progress bar when object is sent to the server. But I don’t know what the code I need to write in doInBackground() method and what the code in onProgressUpdate()
.

Here Client Socket program is used to send Object to the Server.

Code (Inner Class):

class DownloadFileAsync extends AsyncTask<String, String, String> {


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

@Override
protected String doInBackground(String... aurl) {
}

@Override
protected void onProgressUpdate(String... progress) {

}

@Override
protected void onPostExecute(String unused) {

}
}

So, here what I need to write in doInBackground() and in onProgressUpdate()

I have one object serverObject which I need to send to the Server.

Currently I am using following code to send object to the server without any progress bar:

Socket s = new Socket("xxx.xx.xx.xxx", xxx);

//to send object to the server
ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
oos.writeObject(serverObject);
oos.flush();
if (s != null) {s.close();}
if (oos != null) {oos.close();}

how I write this code into doInBackground() method and keep track up to what % data is send.

How to get the size of the object. In lot of site they mention size of the File. But in my case this is a object.

And one more thing to execute this I need to write :

new DownloadFileAsync().execute(params);

So how I get this params.

  • 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-05T09:15:24+00:00Added an answer on June 5, 2026 at 9:15 am

    hi here is the answer of your question please find the link

    this is the example of how you can upload the file to server.

    here is the example you can add the progress bar.

    ProgressDialog pd;
    private final Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            switch(msg.what){
             case 1:
                pd = ProgressDialog.show(this, "uploading...", "Please Wait..", true,false);
                pd.setCancelable(false);
    
              break;
             case 2:
             pd.dismiss();
             break;
            }
    
    }
    };
     new Thread(new Runnable() {                
                @Override
                public void run() {                     
                    try {                   
                             handler.sendEmptyMessage(1);
                             executeMultipartPost(bitmap,filename.jpg);
                             handler.sendEmptyMessage(2);
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }   
    
                }
            }).start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in this example : http://dev.sencha.com/deploy/dev/examples/grid/progress-bar-pager.html if i want to put an delete button, after
hey, hi i want put limit on object creation means a class can have
I want to put the result of the sort method into an array where
I want to know when the status bar changes height as a result e.g.
I would like to put a progressBar on the action bar but setting requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
I am developing winform(c#) that start/stop/restart windows services. I want to put a progress
I've been looking at how to put a progress bar in a TListView in
I have a progress bar and want to fill it in using a separate
I've projected an Intranet Ajax application and I want put it in a full
I want to put a measure in place to stop people from trying to

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.