开发者

Progress notifications from AndroidHttpClient

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 开发者_Go百科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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜