【问题标题】:calculating the percentage downloaded and time remaining while downloading a file on android计算在 android 上下载文件时的下载百分比和剩余时间
【发布时间】:2012-11-07 12:41:07
【问题描述】:

我有一个 android 应用程序,可以将歌曲从服务器下载到设备。我正在为此显示一个进度对话框。我需要显示下载的大小,剩余大小, 经过时间和用户剩余时间

我如何从 Android 中的应用程序中获取这些东西?

任何指针都是最有用的。

问候 伦吉思

【问题讨论】:

  • 这正是 1AsyncTask 的全部意义所在。您应该覆盖 onProgress 并使用 ProgressDialog

标签: java android android-progressbar download


【解决方案1】:

您应该使用异步任务并覆盖 onProgressUpdate()

 @Override
 protected void onProgressUpdate(Integer... values) {
     Log.i("Value", values[0].toString());
     count++;
     progressBar.setProgress(count);
 }

看看这个链接。 Download a file with Android, and showing the progress in a ProgressDialog。链接中的答案应该对您有所帮助。

Calculate Percentage Downloaded and Time Remaining for in OTHER applicationWhat's the best way to calculate remaining download time?

【讨论】:

  • 感谢您的更新。我需要根据带宽添加经过时间和剩余时间
  • 更新了答案。看看链接。
猜你喜欢
  • 2012-08-09
  • 2021-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-16
  • 1970-01-01
相关资源
最近更新 更多