来自 AndroidHttpClient 的进度通知

发布于 2024-12-03 06:37:57 字数 196 浏览 1 评论 0 原文

我正在使用 Android 3.0 和 3.1。 我在应用程序中使用 AndroidHttpClient 类,并使用execute(HttpUriRequest) 来执行。

我的用户界面中有一个进度条,我想在发送数据时更新它。 有没有办法从 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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

厌味 2024-12-10 06:37:57

要跟踪数据发送到服务器的进度,您必须包装正在发送的底层 HTTP 实体。如果您子类 HttpEntityWrapper 并覆盖 writeTo( ) 您可以使用 OutputStream href="http://developer.android.com/reference/java/io/FilterOutputStream.html" rel="nofollow">FilterOutputStream 是写入服务器的流。

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.

小姐丶请自重 2024-12-10 06:37:57

我认为您需要 AsyncTask 示例,也许它会帮助您 ::

  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();

                //}

            }
        }

并在您的主类中使用它 ::

 new xyz().execute();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文