本文介绍了Android:什么是下载管理器文件大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是 Downloadmanager 可下载的文件大小在Android中的限制,因为我正在尝试下载文件大小(700MB),它没有下载,但是当我尝试与 1MB或2MB 它的下载完美。

what's Downloadmanager downloadable File size Limitations in android, because I'm trying to download a file size (700MB) it's not downloaded but when i try same thing with 1MB or 2MB it's download perfect.

所以,任何帮助请

推荐答案

没有文件大小的文件限制,虽然可用的磁盘空间将是一个可能的限制。

There is no documented limitation on file size, though available disk space would be one likely limit.

对于您的下载失败,请使用 DownloadManager.Query 检查您的下载的 COLUMN_STATUS COLUMN_REASON 值,尝试确定发生了什么。

For your failing downloads, use DownloadManager.Query to examine the COLUMN_STATUS and COLUMN_REASON values for your download, to try to determine what is going on.

在,我下载一个文件与 DownloadManager ,我有一个按钮,允许您查看状态信息。

In this sample app, I download a file with DownloadManager, and a I have a button that allows you to view the status information.

当您请求下载时,您会得到一个 int back是一个下载请求ID:

When you request a download, you get an int back that is a download request ID:

lastDownload=mgr.enqueue(req);

当用户点击相应的按钮时,我查询下载状态,将其中一些信息记录到LogCat,并显示一个 Toast

When the user clicks the appropriate button, I query for the download status, log some of that information to LogCat, and show a Toast:

  private void queryStatus(View v) {
    Cursor c=
        mgr.query(new DownloadManager.Query().setFilterById(lastDownload));

    if (c == null) {
      Toast.makeText(getActivity(), R.string.download_not_found,
                     Toast.LENGTH_LONG).show();
    }
    else {
      c.moveToFirst();

      Log.d(getClass().getName(),
            "COLUMN_ID: "
                + c.getLong(c.getColumnIndex(DownloadManager.COLUMN_ID)));
      Log.d(getClass().getName(),
            "COLUMN_BYTES_DOWNLOADED_SO_FAR: "
                + c.getLong(c.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)));
      Log.d(getClass().getName(),
            "COLUMN_LAST_MODIFIED_TIMESTAMP: "
                + c.getLong(c.getColumnIndex(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP)));
      Log.d(getClass().getName(),
            "COLUMN_LOCAL_URI: "
                + c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)));
      Log.d(getClass().getName(),
            "COLUMN_STATUS: "
                + c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)));
      Log.d(getClass().getName(),
            "COLUMN_REASON: "
                + c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON)));

      Toast.makeText(getActivity(), statusMessage(c), Toast.LENGTH_LONG)
           .show();

      c.close();
    }
  }

  private String statusMessage(Cursor c) {
    String msg="???";

    switch (c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS))) {
      case DownloadManager.STATUS_FAILED:
        msg=getActivity().getString(R.string.download_failed);
        break;

      case DownloadManager.STATUS_PAUSED:
        msg=getActivity().getString(R.string.download_paused);
        break;

      case DownloadManager.STATUS_PENDING:
        msg=getActivity().getString(R.string.download_pending);
        break;

      case DownloadManager.STATUS_RUNNING:
        msg=getActivity().getString(R.string.download_in_progress);
        break;

      case DownloadManager.STATUS_SUCCESSFUL:
        msg=getActivity().getString(R.string.download_complete);
        break;

      default:
        msg=
            getActivity().getString(R.string.download_is_nowhere_in_sight);
        break;
    }

    return(msg);
  }

这篇关于Android:什么是下载管理器文件大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 04:29