I am working with Android 3.0 and 3.1. I use the class AndroidHttpClient in my application and for the execute I use execute(HttpUriRequest).

I have a progress bar in the UI that I want to be updated while sending data. Is there any way to get notifications from the AndroidHttpClient about the progress of the data sending (I guess it doesn't send the whole buffer in one shot)?

Thanks

有帮助吗?

解决方案

To track the progress of data as it is sent to the server you have to wrap the underlying HTTP entity that is being sent. If you subclass HttpEntityWrapper and override writeTo() you can wrapper the OutputStream with a FilterOutputStream that is the stream being written to the server.

其他提示

i think you need AsyncTask example , may be it will help you ::

  private class xyz extends AsyncTask<Void, Void, Void> {
            private final ProgressDialog dialog = new ProgressDialog(tranning.this);
            @Override
            protected void onPreExecute() {
                this.dialog.setMessage("Please Wait...");
                this.dialog.show();

                // put your code which preload with processDialog  
            }

            @Override
            protected Void doInBackground(Void... arg0) {

                // put you code here


                return null;
            }
            @Override
            protected void onPostExecute(final Void unused) {
                //if (this.dialog.isShowing()) {
                //  this.dialog.dismiss();

                //}

            }
        }

and use it in your main class ::

 new xyz().execute();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top