문제

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